Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
STRING command in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Amit Manas Dubey
Currently Banned

New User


Joined: 15 Dec 2006
Posts: 22
Location: Mumbai

PostPosted: Tue Jan 22, 2008 4:47 pm    Post subject: STRING command in COBOL
Reply with quote

Hi All,

There is an array which has been defined as below -

053900 05 :AMBS:-H OCCURS 24 TIMES
054000 INDEXED BY
054100 X-:AMBS:-H2
054200 X-:AMBS:-H.
054300 07 :AMBS:-H-DELQ
054400 PIC X.
054500 07 :AMBS:-H-BAL
054600 PIC X.

I want to put AMBS-H-DELQ ocurrences 1-12 in one String. I used the following lines of code, but this isnt working -

PERFORM VARYING X-AMBS-H FROM 1 BY 1 UNTIL X-AMBS-H = 12
STRING FASR-CSR-PYMT-HISTORY DELIMITED BY SIZE
AMBS-H-DELQ (X-AMBS-H) DELIMITED BY SIZE
INTO FASR-CSR-PYMT-HISTORY
END-PERFORM

Pls suggest. FASR-CSR-PYMT-HISTORY is the field where i want to dump my output.

Best regards,
Amit.
Back to top
View user's profile Send private message

murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Tue Jan 22, 2008 4:52 pm    Post subject:
Reply with quote

Amit ,

Your code is NOT easily understandable. Remeber to use 'code' tag atleast from your next post.

If you want to move n occurnce from a table, why dont you 'move' directly using reference modification.
Back to top
View user's profile Send private message
Ajay Baghel

Active User


Joined: 25 Apr 2007
Posts: 205
Location: Bangalore

PostPosted: Tue Jan 22, 2008 4:58 pm    Post subject: Reply to: STRING command in COBOL
Reply with quote

what error are you getting at run time?

I think you need to change the perform condition to below:
Quote:
UNTIL X-AMBS-H = 12



-Ajay
Back to top
View user's profile Send private message
Ajay Baghel

Active User


Joined: 25 Apr 2007
Posts: 205
Location: Bangalore

PostPosted: Tue Jan 22, 2008 5:01 pm    Post subject: Reply to: STRING command in COBOL
Reply with quote

oh forgot to change the condition. It should be:

Quote:
UNTIL X-AMBS-H > 12




-Ajay
Back to top
View user's profile Send private message
Amit Manas Dubey
Currently Banned

New User


Joined: 15 Dec 2006
Posts: 22
Location: Mumbai

PostPosted: Tue Jan 22, 2008 5:16 pm    Post subject:
Reply with quote

HI Ajay

I am getting spaces in the output variable.

@ Murmohkh1 - Can you pls let me know how can I use reference modification for the same ?

Rgds,
Amit.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Tue Jan 22, 2008 5:27 pm    Post subject:
Reply with quote

each time you perform this:
Code:

STRING FASR-CSR-PYMT-HISTORY DELIMITED BY SIZE
            AMBS-H-DELQ (X-AMBS-H) DELIMITED BY SIZE
  INTO FASR-CSR-PYMT-HISTORY


you are stringing FASR-CSR-PYMT-HISTORY into itself. there will be no room for anything else.

either use the pointer option within the perform, or simply without a perform:
Code:

MOVE SPACES (or initialize) TO FASR-CSR-PYMT-HISTORY

STRING AMBS-H-DELQ (1) DELIMITED BY SIZE
       AMBS-H-DELQ (2) DELIMITED BY SIZE
       AMBS-H-DELQ (3) DELIMITED BY SIZE
         ...
       AMBS-H-DELQ (12) DELIMITED BY SIZE
     INTO FASR-CSR-PYMT-HISTORY
END-STRING
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

PostPosted: Tue Jan 22, 2008 5:36 pm    Post subject: STRING command in COBOL
Reply with quote

As an alternative to the STRING verb, give this a try -

Code:

03  WS-POS  PIC  9(008) BINARY.

MOVE SPACES   TO FASR-CSR-PYMT-HISTORY (1:).
MOVE 1        TO WS-POS.
SET  X-AMBS-H TO 1.

PERFORM UNTIL X-AMBS-H > 12
   MOVE AMBS-H (X-AMBS-H)    TO FASR-CSR-PYMT-HISTORY (WS-POS:LENGTH OF AMBS-H (1))
   ADD  LENGTH OF AMBS-H (1) TO WS-POS
   SET  X-AMBS-H             UP BY 1
END-PERFORM.


Regards,

Bill
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

PostPosted: Tue Jan 22, 2008 6:04 pm    Post subject: STRING command in COBOL
Reply with quote

Please substitute -

AMBS-H-DELQ for AMBS-H

and

LENGTH OF AMBS-H-DELQ (1) for LENGTH OF AMBS-H (1).

I misread your post and thought you needed the entire group moved (AMBS-H) as opposed to a group of elementary items (AMBS-H-DELQ) which are subordinate to the group.

Regards,

Bill
Back to top
View user's profile Send private message
Amit Manas Dubey
Currently Banned

New User


Joined: 15 Dec 2006
Posts: 22
Location: Mumbai

PostPosted: Tue Jan 22, 2008 8:23 pm    Post subject: Reply to: STRING command in COBOL
Reply with quote

Thanks guys !!!!

Both the approaches work correctly and yield desired results.

Thanks again.

Regards,
Amit.
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 line 52: Name or string > 250 char... Ashishpanpaliya CLIST & REXX 5 Sat Oct 14, 2017 2:29 am
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts MQ command in option 6 of ISPF! Vignesh Sid All Other Mainframe Topics 3 Tue Sep 26, 2017 6:01 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us