IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need help for Cobol syntex


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sangita

New User


Joined: 02 Jun 2005
Posts: 17

PostPosted: Tue Apr 18, 2006 10:48 am
Reply with quote

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
View user's profile Send private message
sridevi2005

New User


Joined: 15 Sep 2005
Posts: 42

PostPosted: Tue Apr 18, 2006 12:07 pm
Reply with quote

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
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Tue Apr 18, 2006 12:44 pm
Reply with quote

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
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Apr 18, 2006 8:05 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top