MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Table handling

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
dhulipalla
Beginner


Joined: 24 Aug 2004
Posts: 21
Topics: 6

PostPosted: Tue Nov 15, 2005 1:19 pm    Post subject: Table handling Reply with quote

INPUT file
Code:

group      code      fraction
01          A         0.750
01          B         0.250
02          C         0.500
02          D         0.500
03          E         0.250
03          F         0.750

INTERNAL TABLE
Code:

code      amount
A      1000
B       0
C      2000
D      2000
E      1000
F      5000

OUTPUT
Code:

code      amount
A         750
B         250
C         2000
D         2000
E         1500
F         450   


Any idea on achieving the desired output..
Code:
Back to top
View user's profile Send private message
Ravi
Beginner


Joined: 27 Jun 2005
Posts: 88
Topics: 2

PostPosted: Tue Nov 15, 2005 1:23 pm    Post subject: Reply with quote

Can you please explain
>> how the amount in the output is calculated.??
>> What the use of Group in input file?
Back to top
View user's profile Send private message
dhulipalla
Beginner


Joined: 24 Aug 2004
Posts: 21
Topics: 6

PostPosted: Tue Nov 15, 2005 1:29 pm    Post subject: Reply with quote

For example group 1 is having
group amount fraction
A 1000 0.750
B 0 0.250
When you add these codes amount it becomes 1000
and based on the fraction in the input file we need to produce the output.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Nov 15, 2005 1:40 pm    Post subject: Reply with quote

dhulipalla,

Can you give us clear idea about the summing? the summing does not match for other records

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dhulipalla
Beginner


Joined: 24 Aug 2004
Posts: 21
Topics: 6

PostPosted: Tue Nov 15, 2005 1:55 pm    Post subject: Reply with quote

code amount
A 1000
B 0
(A+B) 1000 A=(1000*0.750), B=(1000*0.250)
C 2000
D 2000
(C+D) 4000 C=(4000*0.500), D=(4000*0.500)
E 1000
F 5000
(E+F) 6000 E=(6000*0.250), F=(6000*0.750)


code amount
A 750
B 250
C 2000
D 2000
E 1500
F 4500

I m sorry, F's amount is 4500..
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Nov 15, 2005 3:12 pm    Post subject: Reply with quote

dhulipala,

I don't have a complete requirement of your problem. so I assumed a couple of them. you are going to have a max of 2 records per group and I assumed the following layout for the
input

Code:

01 IN-REC.                                   
   05 IN-CUST-GRP                 PIC X(02). 
   05 IN-CUST-CODE                PIC X(01). 
   05 IN-CUST-FRAC                PIC 9V999. 
   05 FILLER                      PIC X(73). 
                                             



Here is an untested code,

Code:

IDENTIFICATION DIVISION.                     
PROGRAM-ID.    SAMPLE                         
DATE-COMPILED.                               
ENVIRONMENT DIVISION.                         
CONFIGURATION SECTION.                       
INPUT-OUTPUT SECTION.                         
FILE-CONTROL.                                 
                                             
      SELECT INFILE                           
      ASSIGN TO IN1                           
      ORGANIZATION IS SEQUENTIAL.             
                                             
      SELECT OUTFILE                         
      ASSIGN TO OUT1                         
      ORGANIZATION IS SEQUENTIAL.             
                                             
DATA DIVISION.                               
FILE SECTION.                                 
                                             
FD INFILE                                     
    RECORDING MODE IS F                       
    LABEL RECORDS ARE STANDARD               
    BLOCK CONTAINS 0 RECORDS                 
    DATA RECORD IS IN-REC.                   
                                             
01 IN-REC.                                   
   05 IN-CUST-GRP                 PIC X(02). 
   05 IN-CUST-CODE                PIC X(01). 
   05 IN-CUST-FRAC                PIC 9V999. 
   05 FILLER                      PIC X(73). 
                                             
FD OUTFILE                                   
    RECORDING MODE IS F                       
    LABEL RECORDS ARE STANDARD               
    BLOCK CONTAINS 0 RECORDS                 
    DATA RECORD IS OUT-REC.                   

01 OUT-REC.                                             
   05 OUT-CUST-CODE               PIC X(01).           
   05 OUT-CUST-AMT                PIC 9(09).           
   05 FILLER                      PIC X(70).           
                                                       
WORKING-STORAGE SECTION.                               
01 S-EOF-INPUT                 PIC X(01)  VALUE 'N'.   
01 W-GRP-TOTAL                 PIC 9(09) VALUE 0.       
01 W-IND-AMT                   PIC 9(09) VALUE 0.       
01 W-PREV-GRP                  PIC X(02) VALUE SPACES. 
01 W-SUB                       PIC 9 VALUE 0.           
                                                       
01 T-INTERNAL-TABLE-AREA.                               
    05 INTERNAL-TABLE        OCCURS 6 TIMES             
                             ASCENDING KEY IS  T-CODE   
                             INDEXED BY CR-INDEX.       
       10  T-CODE              PIC  X(01).             
       10  T-AMT               PIC  9(09).             
                                                       
                                                       
01 T-OUTPUT-TABLE-AREA.                                 
    05 OUT-TABLE             OCCURS 2 TIMES.           
       10  OUT-CODE            PIC  X(01) VALUE SPACES.
       10  OUT-FRAC            PIC  9V999 VALUE ZERO.   
                                                       
PROCEDURE DIVISION.                                     
                                                       
      OPEN  INPUT  INFILE                               
           OUTPUT  OUTFILE                             
                                                       
      MOVE 'A'    TO T-CODE(1)                         
      MOVE 1000   TO T-AMT (1)                         
                                                       
      MOVE 'B'    TO T-CODE(2)                         
      MOVE 0      TO T-AMT (2)                         
                                                       
      MOVE 'C'    TO T-CODE(3)                         
      MOVE 2000   TO T-AMT (3)                         
                                                       
      MOVE 'D'    TO T-CODE(4)                         
      MOVE 2000   TO T-AMT (4)                         
                                                       
      MOVE 'E'    TO T-CODE(5)                         
      MOVE 1000   TO T-AMT (5)                         
                                                       
      MOVE 'F'    TO T-CODE(6)                         
      MOVE 5000   TO T-AMT (6)                         
                                                       
      PERFORM 2100-READ-INPUT-FILE   
                   
      MOVE IN-CUST-GRP TO W-PREV-GRP                   

      PERFORM 2000-MAIN-PROCESS UNTIL S-EOF-INPUT = 'Y'

      PERFORM 2300-PREP-OUTPUT                         
                                                       
      CLOSE  OUTFILE                                   
                                                       
      GOBACK                                           
      .                                                 
             
 2000-MAIN-PROCESS.                                         
*************************************************************
*THIS PARAGRAPH PERFORMS THE MAIN LOGIC                     *
*************************************************************

      IF IN-CUST-GRP = W-PREV-GRP                           
         ADD +1 TO W-SUB                                     
         MOVE IN-CUST-CODE TO OUT-CODE(W-SUB)               
         MOVE IN-CUST-FRAC TO OUT-FRAC(W-SUB)               
         PERFORM 2200-SEARCH-IN-CUST-CODE                   
         ADD W-IND-AMT TO W-GRP-TOTAL                       
      ELSE                                                   
         PERFORM 2300-PREP-OUTPUT                           
         INITIALIZE T-OUTPUT-TABLE-AREA                     
                    W-GRP-TOTAL                             
                    W-PREV-GRP                               
                    W-SUB                                   
                                                             
         MOVE IN-CUST-GRP TO W-PREV-GRP                     
         ADD +1 TO W-SUB                                     
         MOVE IN-CUST-CODE TO OUT-CODE(W-SUB)               
         MOVE IN-CUST-FRAC TO OUT-FRAC(W-SUB)               
         PERFORM 2200-SEARCH-IN-CUST-CODE                   
         ADD W-IND-AMT TO W-GRP-TOTAL                       
      END-IF                                                 
                                                             
      PERFORM 2100-READ-INPUT-FILE                           
      .                                                     
 2100-READ-INPUT-FILE.                                       
*************************************************************
*THIS PARAGRAPH READS THE INPUT FILE.                       *
*************************************************************
      READ INFILE                                           
         AT END                                             
            MOVE 'Y'              TO S-EOF-INPUT             
      END-READ                                               
      .                                                     
 2200-SEARCH-IN-CUST-CODE.                                   
*************************************************************
*THIS PARAGRAPH SEARCHES THE INTERNAL TABLE.                *
*************************************************************
                                                             
      SEARCH ALL INTERNAL-TABLE                             
          AT END                                             
             MOVE 0               TO W-IND-AMT               
        WHEN T-CODE(CR-INDEX) = IN-CUST-CODE                 
             MOVE T-AMT(CR-INDEX) TO W-IND-AMT               
      END-SEARCH                                             
      .                                                     
 2300-PREP-OUTPUT.                                           
*************************************************************
*THIS PARAGRAPH PERFORMS THE OUTPUT RECORDS.                *
*************************************************************
                                                             
      INITIALIZE OUT-REC                                     
      MOVE OUT-CODE(1) TO OUT-CUST-CODE                     
      COMPUTE OUT-CUST-AMT = OUT-FRAC(1) * W-GRP-TOTAL       
      WRITE OUT-REC                                         
                                                             
      INITIALIZE OUT-REC                                     
      MOVE OUT-CODE(2) TO OUT-CUST-CODE                     
      COMPUTE OUT-CUST-AMT = OUT-FRAC(2) * W-GRP-TOTAL       
      WRITE OUT-REC                                         
      .                 


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dhulipalla
Beginner


Joined: 24 Aug 2004
Posts: 21
Topics: 6

PostPosted: Tue Nov 15, 2005 3:45 pm    Post subject: Reply with quote

Kolusu,

Thanks for the solution..That works for me..
Back to top
View user's profile Send private message
dhulipalla
Beginner


Joined: 24 Aug 2004
Posts: 21
Topics: 6

PostPosted: Tue Nov 15, 2005 4:34 pm    Post subject: Reply with quote

kolusu,

when I run this program it abended with soc7 at this statement
COMPUTE OUT-CUST-AMT = OUT-FRAC(1) * W-GRP-TOTAL
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Nov 15, 2005 6:45 pm    Post subject: Reply with quote

Quote:

when I run this program it abended with soc7 at this statement
COMPUTE OUT-CUST-AMT = OUT-FRAC(1) * W-GRP-TOTAL


Look at the definitions of items involved? is your input data packed? or does your input have the imbedded decimal point in your input ?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dhulipalla
Beginner


Joined: 24 Aug 2004
Posts: 21
Topics: 6

PostPosted: Tue Nov 15, 2005 7:11 pm    Post subject: Reply with quote

Kolusu,

In the input there is an imbedded decimal point ..It's working now..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group