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

STRING command in COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 1436
Location: Bangalore,India

PostPosted: Tue Jan 22, 2008 4:52 pm
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: 206
Location: Bangalore

PostPosted: Tue Jan 22, 2008 4:58 pm
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: 206
Location: Bangalore

PostPosted: Tue Jan 22, 2008 5:01 pm
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
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: 6966
Location: porcelain throne

PostPosted: Tue Jan 22, 2008 5:27 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Jan 22, 2008 5:36 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Jan 22, 2008 6:04 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top