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 

formatted display pgm needed
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
venkats
Beginner


Joined: 09 Jan 2006
Posts: 9
Topics: 1

PostPosted: Mon Jan 09, 2006 12:51 pm    Post subject: formatted display pgm needed Reply with quote

I have a requirement where in i have to write a program to achive the results.
INPUT
-----

Code:

MGR HRD ABC      1
MGR HRD ABC      2
MGR HRD PQR 001 10
MGR HRD PQR 001 20
MGR HRD PQR 002  5
MGR HRD PQR 002  6
MGR HRD XYZ 002  7
MGR HRD XYZ 003  1
MGR HRD XYZ 003  2


OUTPUT
-------

Code:

MGR HRD ABC      1    2
        PQR 001 10   20
            002  5    6
        XYZ 002  7     
            003  1    2


PROGRAM
-------

Code:

01 A .                     
   05 A1 PIC X(3).                 
   05 FILLER PIC X VALUE SPACE.     
   05 A2 PIC X(3).                 
   05 FILLER PIC X VALUE SPACE.     
   05 A3 PIC X(3).                 
   05 FILLER PIC X VALUE SPACE.     
   05 A4 PIC X(3).                 
   05 FILLER PIC X VALUE SPACE.     
   05 A5 PIC 9(2).                 
   05 FILLER PIC X(62) VALUE SPACES.
01 B .                     
   05 B1 PIC X(3).                 
   05 FILLER PIC X VALUE SPACE.     
   05 B2 PIC X(3).                 
   05 FILLER PIC X VALUE SPACE.     
   05 B3 PIC X(3).                 
   05 FILLER PIC X VALUE SPACE.     
   05 B4 PIC X(3).                 
   05 FILLER PIC X VALUE SPACE.     
   05 B5 PIC 9(2).                 
   05 FILLER PIC X(4) VALUE SPACES.
   05 B6 PIC 9(2).                 
   05 FILLER PIC X(56) VALUE SPACES.


My assumptions:
--------------
1.Read the file record by record assuming record to be 80 bytes long and Input record structure is A and OUTPUT record structure is B.
2.

Code:

IF A(1:3) = 'MGR'                                       
 IF A(5:3) = 'HRD'                                     
  IF A(9:3) = 'ABC'                                     
        MOVE A(11:3) TO CORRESPONDING B RECORD STRUCTURE
  ELSE                                                 
     IF A(9:3) = 'PQR'                                 
        MOVE A(11:3) TO CORRESPONDING B RECORD STRUCTURE
     ELSE                                               
        MOVE A(11:3) TO CORRESPONDING B RECORD STRUCTURE
     END-IF                                             
  END-IF                                               
 END-IF                     


Can anybody guide me ahead further as how do i get my results as i am not able to proceed ahead?
Back to top
View user's profile Send private message
SureshKumar
Intermediate


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Mon Jan 09, 2006 1:07 pm    Post subject: Reply with quote

venkats,
This should not be difficult, however, I don't think I will be able to do the cobol code. This depends on how flexible you need the code to be. For the code to be generic you need to think of "contro break" logic. "MGR HRD ABC " MGR would be your first break, HRD second break and so on. Moreover, you are moving values to the column format - what would be the limitation ? if you have 100's of rows for a particulr type how would you fit it - i mean the LRECL. Avoid hardcoding the values unless you are sure it's going to be static. Sorry, could not be much more help.
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: Mon Jan 09, 2006 3:03 pm    Post subject: Reply with quote

Venkats,

I would suggest to declare a 3 dimensional table and load it and work with it to get the desired results.

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
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Mon Jan 09, 2006 3:48 pm    Post subject: Reply with quote

This sounds like a homework problem, and I doubt that the correct answer would involve hardcoding MGR, HDR, ABC, XYZ, etc. You just need to remember the last value in each column and when, scanning left to right, a column changes, you start a new line printing the changed columns (changed and all to the right of the change) with the obvious different printing for the last column.
Back to top
View user's profile Send private message Visit poster's website
venkats
Beginner


Joined: 09 Jan 2006
Posts: 9
Topics: 1

PostPosted: Mon Jan 09, 2006 5:31 pm    Post subject: Reply with quote

Thanks Experts for the views on my query.

My input datset can contain other values in the column for HRD also ,and the output will be accordingly as shown if it exists,please guide me ahead as i am unable to write the code.Kolusu why do we need three dimensional table ,can i have a sample program where in i can understand the steps.Please guide me ahead further to complete the task ?

Code:

MGR HRD ABC      1
MGR HRD ABC      2
MGR HRD PQR 001 10
MGR HRD PQR 001 20
MGR HRD PQR 002  5
MGR HRD PQR 002  6
MGR HRD XYZ 002  7
MGR HRD XYZ 003  1
MGR HRD XYZ 003  2

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 Jan 10, 2006 5:13 am    Post subject: Reply with quote

venkats,

Check this link for table handling

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG10/1.4?DT=20020923143836

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
venkats
Beginner


Joined: 09 Jan 2006
Posts: 9
Topics: 1

PostPosted: Tue Jan 10, 2006 12:07 pm    Post subject: Reply with quote

Kolusu,

Basically the input dataset is derived from the unload of a dataset and i have the query whether we can use 3 dimension table to get the same results and the link provided by you is very useful for me.Can you brief the steps to follow for getting the output and can i have a sample program using 3 dimensional table where in a similar kind of requirement is used ?

It would be helpful for me if you guide me the steps to follow to get the results.
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 Jan 10, 2006 12:16 pm    Post subject: Reply with quote

Venkats,

Check this link for an example

http://www.mvsforums.com/helpboards/viewtopic.php?t=3399&highlight=search+table

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
venkats
Beginner


Joined: 09 Jan 2006
Posts: 9
Topics: 1

PostPosted: Tue Jan 10, 2006 2:59 pm    Post subject: Reply with quote

Kolusu,

Thanks for a very good example which has given me understanding of storing and searching values in a table.I need a slight modification in the desired output by vlady as

Instead of the result showing summation only ,if i need the values of fields as well as SUM how can it be achived assuming the sum to be placed purposefully in ( ).

Code:

EXAMPLE OF DESIRED RESULT SHOWING MONTH OF FEBRUARY ONLY:

02  005  11282003  11282004  02282004  333.00  24.98  50.73   



My desired output:

Code:

EXAMPLE OF DESIRED RESULT SHOWING MONTH OF FEBRUARY ONLY:

02  005  11282003  11282004  02282004  166.50  166.50  (333.00)  12.49  12.49  (24.98)  50.73  (50.73)

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 Jan 10, 2006 3:18 pm    Post subject: Reply with quote

Quote:

Instead of the result showing summation only ,if i need the values of fields as well as SUM how can it be achived assuming the sum to be placed purposefully in ( ).


Load the values into the table and use the intrinsic function sum on all the occurances. check this link for

ie.
Code:
Compute Ws-total = function sum (internal-table-field(ALL))


For individual rows display the contents of the table.

Check this link for the available intrinsic functions


http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR10/7.1?DT=20020920180651

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
venkats
Beginner


Joined: 09 Jan 2006
Posts: 9
Topics: 1

PostPosted: Wed Jan 11, 2006 6:57 am    Post subject: Reply with quote

Hai Kolusu,

Basically my requirement goes this way:

1.The input dataset which is derived from the unload of a dataset is below and the query used is :

Code:

SELECT DIV, HOME, DEPT,NO,STATUS,TEST,   
      SUM(MARKS)                                                     
FROM USERID.EMPLOYEE                                         
WHERE DIV = 'AB' AND NONHOME = '100'                         
    AND HOME IN ('ABCD','EFGH','PQRS','WXYZ')                   
GROUP BY DIV, HOME, DEPT, NO, STATUS, TEST
ORDER BY DIV, HOME, DEPT, NO, STATUS, TEST

                                                                           
DIV   HOME   DEPT  NO     STATUS       TEST               MARKS         
----  -----  ----  -----  ----     --------  ------------------         
AB    PQRS   PAL          F               1                  10         
AB    PQRS   PAL          F               2                  20         
AB    PQRS   PAL          F               3                  30         
AB    PQRS   PAL   001    M               1                  30         
AB    PQRS   PAL   001    M               2                  40         
AB    PQRS   PAL   002    M               1                  99         
AB    PQRS   PAL   002    M               2                  25         
AB    PQRS   PAL   002    M               3                  12         
AB    PQRS   PAL   003    M               1                  11         
AB    PQRS   PAL   003    M               2                  30         
AB    PQRS   PAL   011    M               1                  96         
AB    PQRS   PAL   011    M               2                  65         
AB    PQRS   PAL   012    M               1                  22         
AB    PQRS   PAL   012    M               2                  44         
AB    PQRS   PAL   015    M               1                  36         
AB    PQRS   PAL   015    M               2                  20         
AB    PQRS   PAL   016    M               1                  20         
AB    PQRS   PAL   016    M               2                  15         
AB    PQRS   PAL   020    M               1                  90         
AB    PQRS   PAL   020    M               2                  40         
AB    PQRS   PAL   021    M               1                  30         
AB    PQRS   PAL   021    M               2                   5         
AB    PQRS   PAL   022    M               1                  80         
AB    PQRS   PAL   022    M               2                  88         
AB    PQRS   PAL   070    M               1                  70         
AB    PQRS   PAL   080    M               2                  35         
AB    PQRS   PAL   085    M               1                  70         
AB    PQRS   PAL   085    M               2                  50         
   





2.I have to code a program where in the report appears like this which basically groups as per the given order:




Code:
   

DIV   HOME   DEPT  NO     STATUS  COL1  COL2  COL3 TOTAL
---   ----  -----  ----  -----    ----  ----  ----  ----
12    PQRS   PAL             F      10    20    30    60
                   001       M      30    40          70
                   002       M      99    25    12   136
                   003       M      11    30          41
                   011       M      96    65         161
                   012       M      22    44          66
                   015       M      36    20          56
                   016       M      20    15          35
                   020       M      90    40         130
                   021       M      30     5          35
                   022       M      80    88         168
                   070       M      70                70
                   080       M            35          35
                   085       M      70    50         120
                                  ----  ----  ----  ----               
                   TOTAL                                               
                                   664   477    42  1183               
   

     




Basically the program needs to take care of other HOME values,DEPT values,STATUS values also.

Pre-requisites:

1.The HOME values derived from the unload of the query can contain other values aslo ,this has to be taken care by the program.
2.The DEPT values derived from the unload of the query can contain other values also, this has also to be taken care by the program.
3.The STATUS values derived from the unload of the query can contain other values also, this has also to be taken care by the program.
4.The nos remain the same as derived from the unload of the query.

Please guide me how to go about this requirement.

For example there might be situations where the unloaded dataset might look like that is why i mentioned HOME,DEPT ,STATUS can have other values

Code:

   
DIV   HOME   DEPT  NO     STATUS       TEST               MARKS         
----  -----  ----  -----  ----     --------  ------------------         
AB    ABCD   ABC          D               1                  10         
AB    ABCD   IJK          E               2                  20         
AB    ABCD   PAL          F               3                  30         
AB    ABCD   PAL   001    M               1                  30         
AB    EFGH   ABC   001    M               2                  40         
AB    EFGH   PAL   002    M               1                  99         
AB    EFGH   PAL   002    M               2                  25         
AB    EFGH   PAL   002    M               3                  12         
AB    EFGH   UVW   003    M               1                  11         
AB    PQRS   ABC   003    M               2                  30         
AB    PQRS   ABC   011    M               1                  96         
AB    PQRS   ABC   011    M               2                  65         
AB    PQRS   ABC   012    M               1                  22         
AB    PQRS   ABC   012    M               2                  44         
AB    PQRS   IJK   015    M               1                  36         
AB    PQRS   IJK   015    M               2                  20         
AB    PQRS   IJK   016    M               1                  20         
AB    PQRS   PAL   016    M               2                  15         
AB    PQRS   PAL   020    M               1                  90         
AB    PQRS   PAL   020    M               2                  40         
AB    PQRS   PAL   021    M               1                  30         
AB    PQRS   PAL   021    M               2                   5         
AB    PQRS   PAL   022    M               1                  80         
AB    PQRS   PAL   022    M               2                  88         
AB    PQRS   UVW   070    M               1                  70         
AB    PQRS   UYW   080    M               2                  35         
AB    WXYZ   PAL   085    M               1                  70         
AB    WXYZ   PAL   085    M               2                  50         
   

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: Wed Jan 11, 2006 7:37 am    Post subject: Reply with quote

venkats,

I am Sorry , I cannot code the entire pgm for you. I already have provided samples as to how it can be done.

Thanks

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


Joined: 09 Jan 2006
Posts: 9
Topics: 1

PostPosted: Wed Jan 11, 2006 11:53 am    Post subject: Reply with quote

Kolusu,

Please guide me the steps to follow as i have gone through the sample programs provided by you but my requirement is not particularly based on table key as i am having multiple values in my where clause as shown in the examples.
Please help me out in just highlighting the major steps to follow as there are many kinds of situations which need to be taken care and i will make out the program from my side after your guideance and i will come out with the coding for the program and i understand that coding is not simple for this kind of requirement.
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: Wed Jan 11, 2006 12:11 pm    Post subject: Reply with quote

Quote:

and i understand that coding is not simple for this kind of requirement.


Venkats,

No offence but this is one of the simplest programming exercise.

All you need to compare the records with previous-key

ex:


Code:

01 Input-key.
   05 input-div    pic x(02).
   05 input-home   pic x(04).
   05 input-dept   pic x(03).

01 ws-prev-key.
   05 ws-prev-div    pic x(02).
   05 ws-prev-home   pic x(04).
   05 ws-prev-dept   pic x(03).


Read each record from the file and

Code:

if input-key = ws-prev-key
    populate the marks in the array
else
    perform the summation of the table values
    load the table with new key
    move input-key to ws-prev-key
end-if


You will PERFORM this loop until the end of file.

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
venkats
Beginner


Joined: 09 Jan 2006
Posts: 9
Topics: 1

PostPosted: Wed Jan 11, 2006 12:56 pm    Post subject: Reply with quote

Kolusu thanks for your early reply despite of me coming up with many queries,

My assumption:
--------------

Code:

read-para
   read input-file
      move the fields in the input-key
   end-read


perform until input-eof
   if input-key = ws-prev-key
          populate the marks in the array
   else
      perform the summation of the table values
      load the table with new key
           move input-key to ws-prev-key
   end-if
   perform read-para
end-perform


I have few queries in the pseudo-code provided by you.

If i am reading record starting from the first and storing the key in input-key,so the key becomes ABPQRSPAL and we are checking the input-key with ws-prev-key which does not have any value and the condition will fail so,i am not able to get what exactly summation of table values means.

Next load the table with the new key means ,we will be storing the fields formed by input-key to a table which has the key defination and move the input-key to ws-prev-key ,so in this case ws-prev-key will have ABPQRSPAL .

Again we read the next record and move the fields in the input-key ,at present the condition will satisfy and we will populate the value of marks 20 .I am not clear with the concept of ws-prev-key ,how is the previous key brought up,can u please brief me the sequence of processing with some sample input.
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
Goto page 1, 2  Next
Page 1 of 2

 
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