View previous topic :: View next topic
|
Author |
Message |
Sangita
New User
Joined: 02 Jun 2005 Posts: 17
|
|
|
|
i have two strings in the cobol.
05 WS-COUNTRY PIC X(30). (COMING FROM FLAT FILE)
05 WS-SUBJECT-LINE PIC X(12) VLAUE 'YEARLY REPORT'
I need report as
<COUNTRY NAME> YEARLY REPORT. (should be one space between country and yearly report)
This country Name will be vary Like..
SOUTH AFRICA.
INDIA.
UNITED STATES OF AMERICA.
My question is
how can i append countries like SOUTH AFRICA and United States Of America in the report statment.
Thanks & regards
Sangita |
|
Back to top |
|
|
sridevi2005
New User
Joined: 15 Sep 2005 Posts: 42
|
|
|
|
Hi Sangita,
First do one thing concate both the strings into a single string using
'String'.
After that use the following code for removing the spaces between County name and yearly report.
perform ws-sub varying from 1 by 1 until ws-sub > 42
MOVE WS-STRING(WS-SUB:1) TO
WS-STRING1(WS-SUBA:1)
IF WS-STRING(WS-SUB:1) NOT = SPACE
MOVE 0 TO WS-SPACE-CNT
ADD 1 TO WS-SUBA
ELSE
IF WS-SPACE-CNT = 0
ADD 1 TO WS-SPACE-CNT
ADD 1 TO WS-SUBA
END-IF
END-IF
END-PERFORM.
I think this will help to u.
Thanks,
Sridevi |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Sangita,
Declare a variable
WS-STRING1 PIC X(42).
put this code
String WS-COUNTRY
delimited by size
' '
WS-SUBJECT-LINE
delimited by size
into WS-STRING1
Hope it will helpful |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Sangita,
Here?s one more solution.
Code: |
WORKING-STORAGE SECTION.
01 WS-COUNTRY PIC X(30) VALUE
'UNITED STATES OF AMERICA'.
01 WS-SUBJECT-LINE PIC X(15) VALUE
'YEARLY REPORT'.
01 WS-TITLE-LINE PIC X(80).
01 SUB PIC S9(3) COMP-3.
LINKAGE SECTION.
PROCEDURE DIVISION.
*--- MOVE COUNTRY TO REPORT TITLE LINE
MOVE WS-COUNTRY TO WS-TITLE-LINE.
*--- FIND LAST NON SPACE CHAR IN REPORT TITLE LINE
PERFORM
VARYING SUB FROM 80 BY -1
UNTIL WS-TITLE-LINE(SUB:1) NOT = ' '
OR SUB < 1
END-PERFORM.
*--- MOVE IN SUBJECT AFTER COUNTRY
MOVE WS-SUBJECT-LINE TO WS-TITLE-LINE(SUB + 2:).
DISPLAY WS-TITLE-LINE.
GOBACK.
|
Results:
Code: |
UNITED STATES OF AMERICA YEARLY REPORT
|
Dave |
|
Back to top |
|
|
|