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

Substring number between 2 characters and prefix with zero


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sikkandhar

New User


Joined: 03 Dec 2007
Posts: 61
Location: Bangalore

PostPosted: Tue Jan 09, 2024 2:48 am
Reply with quote

Hello All,

I have a file from which I need to extract a number and prefix with zeroes

Code:

"a1234-2345-7890_1","abcde"
"a1234-2345-7890_12","abcde"
"a1234-2345-7890_23","abcde"
"a1234-2345-7890_4","abcde"
"a1234-2345-7890_5","abcde"
"a1234-2345-7890_600","abcde"
"a1234-2345-7890_7","abcde"
"a1234-2345-7890_58","abcde"


I need to extract the number between _ and ",", and pad with zeroes, to make it 9 bytes. Till the position of _ it is fixed.
It is a FB file with lrecl as 1000.

my output should look like
Code:

000000001
000000012
000000023
000000004
000000005
000000600
000000007
000000058


Thanks in Advance
Sikkandhar
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1337
Location: Bamberg, Germany

PostPosted: Tue Jan 09, 2024 3:11 am
Reply with quote

Code:
INREC PARSE=(%=(STARTAT=C'_',FIXLEN=1), 
             %01=(STARTAT=NUM,FIXLEN=9)),
  BUILD=(%01,SFF,M11)

Use ABSPOS for the starting offset if you want to have it even more simplified.

Code:
****** *************
000001 000000001   
000002 000000012   
000003 000000023   
000004 000000004   
000005 000000005   
000006 000000600   
000007 000000007   
000008 000000058   
****** *************
Back to top
View user's profile Send private message
Sikkandhar

New User


Joined: 03 Dec 2007
Posts: 61
Location: Bangalore

PostPosted: Tue Jan 09, 2024 3:30 am
Reply with quote

Thanks Joerg
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Increase the number of columns in the... IBM Tools 3
No new posts Reading dataset in Python - New Line ... All Other Mainframe Topics 22
Search our Forums:

Back to Top