best logic method in cobol for new requirement



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

best logic method in cobol for new requirement

Postby lakshmi narayanan » Mon May 03, 2010 9:20 am

Hi,
I have a requirement as below.

INPUT:

ABCDL<DATE>00000XYZ900001 M900001 1234EFGH2 000200000000 1A3G 5678
ABCDX<DATE>00000XYZ900002 M900002 1234EFGH2 000200000000 1234 8765
ABCDL<DATE>00000XYZ900003 M900003 1234EFGH2 000300000000 1A3G 5678
ABCDX<DATE>00000XYZ900004 M900004 1234EFGH2 000300000000 1234 8765

OUTPUT:

My requirement is that i need to sum both values(000200000000 and 000300000000) and write it as a single L,X record as below.
ABCDL<DATE>00000XYZ900001 M900001 1234EFGH2 000500000000 1A3G 5678
ABCDX<DATE>00000XYZ900002 M900002 1234EFGH2 000500000000 1234 8765

If the value is greater than 50 mn,then i have to write as two separate records as below.

INPUT:

ABCDL<DATE>00000XYZ900001 M900001 1234EFGH2 000400000000 1A3G 5678
ABCDX<DATE>00000XYZ900002 M900002 1234EFGH2 000400000000 1234 8765
ABCDL<DATE>00000XYZ900003 M900003 1234EFGH2 000300000000 1A3G 5678
ABCDX<DATE>00000XYZ900004 M900004 1234EFGH2 000300000000 1234 8765

Output:

ABCDL<DATE>00000XYZ900001 M900001 1234EFGH2 000500000000 1A3G 5678
ABCDX<DATE>00000XYZ900002 M900002 1234EFGH2 000500000000 1234 8765
ABCDL<DATE>00000XYZ900003 M900003 1234EFGH2 000200000000 1A3G 5678
ABCDX<DATE>00000XYZ900004 M900004 1234EFGH2 000200000000 1234 8765

If the input is X,L(FIFTH CHARACTER IN INPUT FILE) then i need to subtract the values.

INPUT:

ABCDL<DATE>00000XYZ900001 M900001 1234EFGH2 000200000000 1A3G 5678
ABCDX<DATE>00000XYZ900002 M900002 1234EFGH2 000200000000 1234 8765
ABCDX<DATE>00000XYZ900003 M900003 1234EFGH2 000300000000 1A3G 5678
ABCDL<DATE>00000XYZ900004 M900004 1234EFGH2 000300000000 1234 8765

OUTPUT:(note that 4th character of first record is X)(20-30=-10). - indicates X record.

ABCDX<DATE>00000XYZ900001 M900001 1234EFGH2 000100000000 1A3G 5678
ABCDL<DATE>00000XYZ900002 M900002 1234EFGH2 000100000000 1234 8765


Also,i need to update the tables(db2),for the values(900003,900004)with 900001.

LOGIC:
how can i store the numbers(900001) in internal table and update the values in db2.
lakshmi narayanan
 
Posts: 4
Joined: Thu Apr 29, 2010 12:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: best logic method in cobol for new requirement

Postby William Thompson » Mon May 03, 2010 10:39 am

INPUT:

ABCDL<DATE>00000XYZ900001 M900001 1234EFGH2 000200000000 1A3G 5678
ABCDX<DATE>00000XYZ900002 M900002 1234EFGH2 000200000000 1234 8765
ABCDX<DATE>00000XYZ900003 M900003 1234EFGH2 000300000000 1A3G 5678
ABCDL<DATE>00000XYZ900004 M900004 1234EFGH2 000300000000 1234 8765

OUTPUT:(note that 4th character of first record is X)(20-30=-10). - indicates X record.
Huh?
William Thompson
 
Posts: 81
Joined: Sat Jun 09, 2007 4:24 am
Location: Tucson AZ
Has thanked: 0 time
Been thanked: 1 time

Re: best logic method in cobol for new requirement

Postby lakshmi narayanan » Mon May 03, 2010 11:43 am

hi my requirement is as below.
MY INPUT RECORDS ARE AS FOLLOWS.

ABCD L <DATE>00000XYZ900001 M900001 1234EFGH2 000200000000 1A3G 5678
ABCD X <DATE>00000XYZ900002 M900002 1234EFGH2 000200000000 1234 8765

ABCD X <DATE>00000XYZ900003 M900003 1234EFGH2 000300000000 9875 4321
ABCD L <DATE>00000XYZ900004 M900004 1234EFGH2 000300000000 6758 3204

output:


I need to sum up the values(200000000and 3000000000) for the records(1234EFGH2 ).My first record has fifth character as L.I need to skip the second record which has 'X' as fifth character and 1234 8765.

my third record has X.it indicates the value is negative which is -300000000.in such a case i need to subtract the values(2000000-30000000) which is -100000000. so,my output record is

ABCD X <DATE>00000XYZ900003 M900003 1234EFGH2 000300000000 9875 4321
ABCD L <DATE>00000XYZ900004 M900004 1234EFGH2 000300000000 6758 3204


SCENARIO 2:

ABCD L <DATE>00000XYZ900001 M900001 1234EFGH2 000200000000 1A3G 5678
ABCD X <DATE>00000XYZ900002 M900002 1234EFGH2 000200000000 1234 8765

ABCD L <DATE>00000XYZ900003 M900003 1234EFGH2 000300000000 1A3G 5678
ABCD X <DATE>00000XYZ900004 M900004 1234EFGH2 000300000000 1234 8765

OUTPUT:

ABCD L <DATE>00000XYZ900001 M900001 1234EFGH2 000500000000 1A3G 5678
ABCD X <DATE>00000XYZ900002 M900002 1234EFGH2 000500000000 1234 8765

NOTE:IF INPUT RECORD IS L AND X,IT WILL HAVE
1A3G 5678 FOR L
1234 8765 FOR X

IF INPUT RECORD IS X,L THEN

9875 4321 FOR X
6758 3204 FOR L
lakshmi narayanan
 
Posts: 4
Joined: Thu Apr 29, 2010 12:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: best logic method in cobol for new requirement

Postby William Thompson » Mon May 03, 2010 12:22 pm

I may not be the brightest bulb in the closet, but 'Huh?'

Please try describing your 'requirement' in words, words that explain the convoluted series of input and output examples and exceptions.
William Thompson
 
Posts: 81
Joined: Sat Jun 09, 2007 4:24 am
Location: Tucson AZ
Has thanked: 0 time
Been thanked: 1 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post