Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need help for Cobol syntex

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Need help for Cobol syntex
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    Post subject: Re: Need help for Cobol syntex
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: 1187
Location: Bangalore,India

PostPosted: Tue Apr 18, 2006 12:44 pm    Post subject:
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    Post subject: Re: Need help for Cobol syntex
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us