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

Converting S9(18) value to a decimal value for table


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

New User


Joined: 03 Dec 2020
Posts: 6
Location: India

PostPosted: Tue Feb 22, 2022 7:00 pm
Reply with quote

Hi Team,

1) Variable - A1 belongs to an input file and is defined as below.

A1 PIC s9(18).

2) Column name - B1 belongs to a table - EMP and is defined as below.

B1 - Datatype (DECIMAL) and Length - (7)

Now, in one of our process the value of A1 is compared with B1 and if they are not equal the job fails, I need to update the B1 value as equal to the value of A1 and rerun it again.

So, i have tried to convert the value of A1 using the below sort card to feed the Column B1.
(the first 1-18 positions belongs to the value A1 in the input file).

SORT FIELDS=COPY
OUTREC FIELDS=(1,8,BI,TO=ZD,LENGTH=7)

below is the sample A1 value - input given for the sort job.
00000000000000001A
00000000000000000B
00000000000000007D

the output is same for all three inputs mentioned above.
8401520

Clearly, This value doesn't work when we updated on the table for the column B1.

can you please guide me on how to convert the value of A1 to suit the column B1, if there are any manuals or links i should go thru on this regard please advise.

Thanks in advance
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Tue Feb 22, 2022 8:10 pm
Reply with quote

Your samples of A1 value look like PIC S9(18) COMP-3, but not PIC S9(18)

In SORT notation it is equivalent to PD,10, not BI,8

Check your data formats carefully, and Read the Manuals (mandatory).
Back to top
View user's profile Send private message
jaguyria

New User


Joined: 15 Feb 2022
Posts: 21
Location: Portugal

PostPosted: Wed Feb 23, 2022 9:08 am
Reply with quote

Hello mframe-guy,

Why do you want to do the comparison in JCL directly and not in a program called in JCL?
I think it's easier if you develop a program that reads your input file until the end of the file and compares the variable A1 that was read in the file with the variable B1 read of a table DB2 for example, that you fill at each read of the file. And if A1 is different of B1, write in the output file B1 instead of A1 (as I show below).

In the program you can define the variable A1 as a COMP:
A1 PIC S9(18) COMP.

And define the variable B1 as :
B1 PIC S9(7)V9(2) => example if your variable B1 is signed "S" with "7" integers and "2" decimals

In the cycle of the read until EOF (end of file) you can compare if A1 = B1 it's good, Move A1 to A1-OUT, else Move B1 to A1-OUT, and after you must write it in the output file.
IF A1 = B1
MOVE A1 TO A1-OUT
ELSE
MOVE B1 TO A1-OUT
END-IF

WRITE Output file. (with A1-OUT)
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Wed Feb 23, 2022 6:48 pm
Reply with quote

jaguyria wrote:

Why do you want to do the comparison in JCL directly and not in a program called in JCL?

Absolutely NO COMPARISON can be done in JCL. It is BS.

jaguyria wrote:
I think it's easier if you develop a program that reads your input file until the end of the file and compares the variable A1 that was read in the file with the variable B1 read of a table DB2 for example, that you fill at each read of the file. And if A1 is different of B1, write in the output file B1 instead of A1 (as I show below).

It is not good idea to write a separate program in order to make any operation on data, like 2+2. The only reason for that might be: lack of knowledge, how to do it in a more simple way.

jaguyria wrote:
In the program you can define the variable A1 as a COMP:
A1 PIC S9(18) COMP.

From the samples provided by TS one can only state that the data format is definitely not PIC S9(18).
Is it really COMP, or COMP-3 (or whatever else) - this is the first question TS has to answer to himself, but looks like TS is not interested in any investigation.
I really doubt it may be S9(18) COMP, because this does not fit into 4-bytes binary field. Besides of this, all samples do have hexadecimal "signs" at their end: A-F
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Wed Feb 23, 2022 7:48 pm
Reply with quote

The field A1 maybe really PIC S9(18); in that case it can be converted as
BUILD=(1,18,ZD,TO=...)

The field B1, when defined as "DECIMAL", seems to be coming from DB2, isn't it? Why do we need to guess all these details, and pull them out of TS, one by one?

The type DECIMAL(7) in DB2 is equivalent to PIC S9(7) COMP-3 in COBOL, and PD,4 in SORT notation.

If so, the conversion of A1 to B1 format in SORT needs to be done as follows
Code:
BUILD=(1,18,                     leave source A1 as it is
    19:1,18,ZD,TO=PD,LENGTH=4)   append the converted PD value at pos 19


All this is a result of guessing, because TS refuses to provide any clear information on his goal.
Back to top
View user's profile Send private message
jaguyria

New User


Joined: 15 Feb 2022
Posts: 21
Location: Portugal

PostPosted: Thu Feb 24, 2022 1:42 am
Reply with quote

sergeyken I've suggested making a program so he can easily update the value A1 in the variable B1 of the table (DB2 I guess? cause I'm not really sure).
By the way what does it means "TS" ? (english is not my mother language)
------------------------------------------------------------------------------------
mframe-guy can you please be more specific in what you pretend ?

Quote:
2) Column name - B1 belongs to a table - EMP and is defined as below.
B1 - Datatype (DECIMAL) and Length - (7)

1- Table EMP -> what does that means? Is that DB2 or other language?
2- Decimal with length 7 it's a S9(7) ?

Quote:
I need to update the B1 value as equal to the value of A1 and rerun it again.

1- Do you need to update the value B1 in a table DB2 with the value A1 of the file? If yes, it's ok, but why do you say "rerun it again"?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Thu Feb 24, 2022 3:29 am
Reply with quote

TS = Topic Starter, who is the least interested person in resolving his own issue.
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 Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
Search our Forums:

Back to Top