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).
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.
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
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
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.
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"?