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

Add number and replace the current filed


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

New User


Joined: 23 Apr 2008
Posts: 39
Location: Hyderabad

PostPosted: Fri May 29, 2009 3:17 pm
Reply with quote

HI,

i have a request that i have fileds that are integer(unit number) and decimal(13,0) (reference number) .
i need to add a number for the current fileds and replce the added number

i.e,

if unit number is 1 i need to add 950000000 to this and replace 1 with 950000001

similarly if reference number is 1 i need to add 8800000000000 and replace 8800000000001

any suggestions is greatly appreciated


Regards,
Narasimha
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri May 29, 2009 8:31 pm
Reply with quote

It's not clear what you want to do.

Where will this reference number come from? Another file? A hardcoded constant? Something else?

Please show an example of the records in your input file or files (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input file(s). Give the starting position, length and format of the relevant fields.
Back to top
View user's profile Send private message
Naraismha Reddy

New User


Joined: 23 Apr 2008
Posts: 39
Location: Hyderabad

PostPosted: Sat May 30, 2009 12:12 am
Reply with quote

may be this would help

Code:

---------+---------+---------+---------+---------+---------+---------+---------+
CITM_CLUSTER_NBR CITM_ACCT_NBR     CITM_UNIT_NBR CITM_UNIT_NBR_SEQ CITM_ITM_REF_NBR
---------+---------+---------+---------+---------+---------+---------+---------+
      311 00000000000225496          1521                 3             123,
      311 00000000000225496         99999                13      9999999999,
      311 00000000000225496        333045               144      7000000030,
      315 00000000000214316        999999                62      5000000001,
      311 00000000000225496       5372045                 1         1234567,
      312 00000000000225496       9999999                13      9876543210,
      314 00000000000222773      10228005                 7      1234567890,
      311 00000000000225496      99999999               144               5,
      315 00000000000219690     700000066                 1        10000000,
      312 00000000000225496     900333333                 3               8,
-------------------------------------------------------------------------------------


the ouput expected is

Code:

---------+---------+---------+---------+---------+---------+---------+---------+
CITM_CLUSTER_NBR CITM_ACCT_NBR     CITM_UNIT_NBR CITM_UNIT_NBR_SEQ CITM_ITM_REF_NBR
---------+---------+---------+---------+---------+---------+---------+---------+

      311 00000000000225496     950001521                 3   8800000000123,
      311 00000000000225496     950099999                13   8809999999999,
      311 00000000000225496     951333045               144   8807000000030,
      315 00000000000214316     951999999                62   8805000000001,
      311 00000000000225496     952372045                 1   8800001234567,
      312 00000000000225496     952999999                13   8809876543210,
      314 00000000000222773     953228005                 7   8801234567890,
      311 00000000000225496     953999999               144   8800000000005,
      315 00000000000219690     954000066                 1   8800010000000,
      312 00000000000225496     954333333                 3   8800000000008,

-------------------------------------------------------------------------------------


I have shown this information from the copy book layout

originall the CITM_UNIT_NBR is integer and CITM_ITM_REF_NBR is decimal(13,0)

If CITM_UNIT_NBR between 0 and 99999 then it must be replaced with 950000000 with actual value added.
If CITM_UNIT_NBR between 100000 and 999999 then it must be replaced with 951000000 with actual value added.
If CITM_UNIT_NBR between 1000000 and 9999999 then it must be replaced with 952000000 with last six digits of actual value added.
If CITM_UNIT_NBR between 10000000 and 99999999 then it must be replaced with 953000000 with last six digits of actual value added.
If CITM_UNIT_NBR > 10000000 then it must be replaced with 954000000 with last six digits of actual value added.


both input and output datasets are Variable block with LRECL=448

CITM_UNIT_NBR starts at position 20 and CITM_ITM_REF_NBR starts at position 34


Thanks,
Narasimha
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat May 30, 2009 12:58 am
Reply with quote

That helps. When you say CITM_UNIT_NBR starts at 20, is that including the RDW in positions 1-4 or does it really start at position 24. Same questions for CITM_ITM_REF_NBR - position 34 or position 38?

Is CITM_UNIT_NBR 9 bytes long? Is CITM_ITM_REF_NBR 13 bytes long?

Your example doesn't really line up at the position you say, but it only matters where those two fields start.
Back to top
View user's profile Send private message
Naraismha Reddy

New User


Joined: 23 Apr 2008
Posts: 39
Location: Hyderabad

PostPosted: Sat May 30, 2009 6:26 am
Reply with quote

The CITM_UNIT_NBR starts at position 24 including the RDW and same with CITM_IRM_REF_NBR it stats at position 38.

yes
CITM_UNIT_NBR 9 bytes long and CITM_ITM_REF_NBR 13 bytes long
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Jun 01, 2009 9:09 pm
Reply with quote

Based on your example and description, you can use a DFSORT job like the following. I assumed you didn't really need to add 8800000000000, but could just overlay in the '880' and add leading zeros for the rest of the number.

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
    OVERLAY=(38:C'880',41,10,UFF,TO=ZD,LENGTH=10)),
   IFTHEN=(WHEN=(24,9,UFF,LE,99999),
    OVERLAY=(24:C'950',27,6,UFF,TO=ZD,LENGTH=6)),
   IFTHEN=(WHEN=(24,9,UFF,GE,100000,AND,24,9,UFF,LE,999999),
    OVERLAY=(24:C'951',27,6,UFF,TO=ZD,LENGTH=6)),
   IFTHEN=(WHEN=(24,9,UFF,GE,1000000,AND,24,9,UFF,LE,9999999),
    OVERLAY=(24:C'952')),
   IFTHEN=(WHEN=(24,9,UFF,GE,10000000,AND,24,9,UFF,LE,99999999),
    OVERLAY=(24:C'953')),
   IFTHEN=(WHEN=(24,9,UFF,GE,10000000),
    OVERLAY=(24:C'954'))
/*
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 Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top