IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 K              PIC 9(10).
01 S              PIC X(100).

PROCEDURE DIVISION.
  ACCEPT K.
  ACCEPT S.
  IF K < FUNCTION STORED-CHAR-LENGTH(S)
      DISPLAY S(1 : K) "..."
  ELSE
      DISPLAY FUNCTION TRIM(S)
  END-IF.
  STOP RUN.
