2006 Aug 11 9:30 AM
Hi my requirement goes like this:
I need to transfer header and item data into file in application server.
I need to create separate file for plant (multiple selection field)
However i have a specific requirement which i am not able to map and it is:
<b>when only header entries exists for a particular scenario then item fields should come blank ( which is fine )
when only item entries exists for a particular scenario the corresponding fields of item should be filled for header entries ( they have some similar fields).</b>
Presently i am looping thru header table , then at new plant creating file and opening it in app. server, then i am tranferring header record and after looping item table and using parallel cursor transferring item records.then at end of plant closing file.
However the addtional functionality (marked with bold letter) i am not able to map it out.
Can anyone assist
Regards,
Simran
Simran,
Hope you are populating the header and item data into two different internal tables. Before you start looping, do a read to your header internal table to see whether you have a corresponding header. If <b>sy-subrc value is not equal to 0</b> then loop at the item table and populate the header values and use the normal way of getting the item fields for the corresponding header when <b>sy-subrc value is 0.</b>
Cheers
JK
2006 Aug 11 9:40 AM
Simran,
Hope you are populating the header and item data into two different internal tables. Before you start looping, do a read to your header internal table to see whether you have a corresponding header. If <b>sy-subrc value is not equal to 0</b> then loop at the item table and populate the header values and use the normal way of getting the item fields for the corresponding header when <b>sy-subrc value is 0.</b>
Cheers
JK
2006 Aug 11 11:33 AM
Hi.
i have an issue:
i will try to map my requirement here:
Loop at i_H1( main header table)
from which i get
Header1,header2,header3,header4,header5
then
Read another header table i_H2
from which i get
Header6
Read another header table i_H3
from which i get Header7 and Header 8
Now i am using
At new 'field'
creating file
transfer header records.
Loop at i_I1 from syindex
from which i get
Item 1, Item 2
Read i_I2
from which i get
Item 3
transfer item records.
endloop " I_I1
at end of 'field'
close file
Endloop " i_H1
Now my requirement is if some records exists only in I_H1
and not in I_I1 then ,item fields (item1,item2,item3) should come blank (which is fine)
But,
if some records exists only in I_I1 and not in I_H1 then the header fields should be filled with correponding item fields.
ex. i_H1-header1 = i_I1-header1
(Header1 is a common field)
How to handle this logic?
Regards,
Gunjan
2006 Aug 11 11:39 AM
As you suggested:
Hope you are populating the header and item data into two different internal tables. <b>Before you start looping, do a read to your header internal table to see whether you have a corresponding header.</b> If sy-subrc value is not equal to 0 then loop at the item table and populate the header values and use the normal way of getting the item fields for the corresponding header when sy-subrc value is 0.
Can you clarify the section marked in bold?
Simran
2006 Aug 11 11:54 AM
Hello Simran,
Your defined situations can't be achieved in a single loop or it would be very complex to do that. The solution I would suggest is as below.
Situation 1- Exists in header and not in item.
Loop at I_H1.
...
loop at i_I1 (for I_H1).
endloop.
if sy-subrc <> 0.
clear the item fields (your situation)
transfer item record.
endif.
endloop.
Situation 2. - Exists in Item and not in Header
Loop at I_I1.
read table I_H1 using the link.
if sy-subrc <> 0.
initialise the header files as required and tranfer the header data.
endif.
endloop
Regards
Anurag
2006 Aug 11 11:51 AM
loop at it_item.
lv_tabix = sy-tabix.
at new <header key field>
read it_header with key <header key field> = it_item-<header key field.
if sy-subrc = 0.
read it_item index lv_tabix.
move-corresponding it_item to it_header.
insert it_header.
endif.
endat.
endloop.
loop at it_header.
at new plant. "This wil not work if plant is not your first field
open dataset dsn for output.
endat.
transfer it_header to dsn.
loop at it_item where <header key field> = it_header-<header key field>.
transfer it_item to dsn.
endloop.
at end of plant.
close dataset.
endat.
endloop.
endloop.
Regards,
ravi
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |