Hi,
I need to parse only strings in below record using COBOL. Record has strings and sequence numbers. i need to take strings alone.
Please help me how to do.
MAINFRAME001
DOCUMENTATION002
FILES003
DATABSE004
Parsing strings in COBOL
-
- Posts: 7
- Joined: Fri Jun 17, 2022 9:59 pm
- Skillset: Mainframe - COBOL,JCL,DB2,VSAM
- Referer: internet
-
- Global moderator
- Posts: 3720
- Joined: Sat Dec 19, 2009 8:32 pm
- Skillset: Systems programming, SAS, COBOL, CICS, JCL, SMS, VSAM, etc.
- Referer: other forum
- Location: Dubuque, Iowa, USA
Re: Parsing strings in COBOL
As with your other post, your problem description lacks a LOT of the necessary details.
- Are the sequence numbers always at the end of the string?
- Are all the sequence numbers three digits?
- How long can the strings be?
- When you say "take the strings' what are you going to do with them?
For the sample data you provided, it is a minor process to peel off the last 3 digits from each value (using intrinsic functions and reference modification).
- Are the sequence numbers always at the end of the string?
- Are all the sequence numbers three digits?
- How long can the strings be?
- When you say "take the strings' what are you going to do with them?
For the sample data you provided, it is a minor process to peel off the last 3 digits from each value (using intrinsic functions and reference modification).
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: Parsing strings in COBOL
kanipriya2785 wrote:Hi,
I need to parse only strings in below record using COBOL. Record has strings and sequence numbers. i need to take strings alone.
Please help me how to do.Code: Select all
MAINFRAME001
DOCUMENTATION002
FILES003
DATABSE004
1) Please, learn how to use the Code button to format parts of the code in your postings.
2) Please, try to read something about UNSTRING statement in COBOL
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Posts: 7
- Joined: Fri Jun 17, 2022 9:59 pm
- Skillset: Mainframe - COBOL,JCL,DB2,VSAM
- Referer: internet
Re: Parsing strings in COBOL
Hi,
Here is my answers for your questions. Here there is no delimiter in the string. What function should i use to extract the String value alone?
- Are the sequence numbers always at the end of the string? -> yes.
- Are all the sequence numbers three digits? - yes
- How long can the strings be? - it is variable length.
- When you say "take the strings' what are you going to do with them? -> I need them to pass into another program as input.
Here is my answers for your questions. Here there is no delimiter in the string. What function should i use to extract the String value alone?
- Are the sequence numbers always at the end of the string? -> yes.
- Are all the sequence numbers three digits? - yes
- How long can the strings be? - it is variable length.
- When you say "take the strings' what are you going to do with them? -> I need them to pass into another program as input.
-
- Global moderator
- Posts: 3720
- Joined: Sat Dec 19, 2009 8:32 pm
- Skillset: Systems programming, SAS, COBOL, CICS, JCL, SMS, VSAM, etc.
- Referer: other forum
- Location: Dubuque, Iowa, USA
Re: Parsing strings in COBOL
Use FUNCTION REVERSE() to reverse the string.
Use FUNCTION TRIM( , LEADING) on the reversed string to remove leading spaces.
Use reference modification to move characters from the reversed, trimmed string starting with the 4th to another variable (which strips the sequence number).
Use FUNCTION REVERSE to get the string back in original sequence. Depending upon your lengths and desired output, you may need to use FUNCTION TRIM as well.
Use FUNCTION TRIM( , LEADING) on the reversed string to remove leading spaces.
Use reference modification to move characters from the reversed, trimmed string starting with the 4th to another variable (which strips the sequence number).
Use FUNCTION REVERSE to get the string back in original sequence. Depending upon your lengths and desired output, you may need to use FUNCTION TRIM as well.
-
- Posts: 7
- Joined: Fri Jun 17, 2022 9:59 pm
- Skillset: Mainframe - COBOL,JCL,DB2,VSAM
- Referer: internet
Re: Parsing strings in COBOL
Thank you. I will try this. Thanks for your timely help.
-
- Similar Topics
- Replies
- Views
- Last post
-
- 0
- 2201
-
by laksh0901
View the latest post
Mon Sep 30, 2024 5:10 pm
-
-
Parsing more than 1000 columns in a sort card Reply with quo
by ssuthagar » Tue Sep 22, 2020 3:02 am » in Syncsort/Synctool - 1
- 3433
-
by sergeyken
View the latest post
Tue Sep 22, 2020 9:06 pm
-
-
- 2
- 3128
-
by enrico-sorichetti
View the latest post
Mon Oct 30, 2023 6:25 pm
-
- 12
- 12629
-
by Robert Sample
View the latest post
Thu Dec 15, 2022 9:28 pm
-
- 2
- 4415
-
by sergeyken
View the latest post
Sat Nov 11, 2023 3:01 am