Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Header and Item of the Internal table in different line in text file

Former Member
0 Kudos

Hi,

I have four field in header and corresponding 5 fields of the item.I want to populate the internal table like that.and after that I want to download to the text file.

the internal table should be populated in the followings structure :


H1   |  H2   |    H3    |  H4   |
hv1 |  hv2  |   hv3   |  hv4 |
I1    |  I2     |    I3      |  I4    |  I5  |
iv1  |  iv2   |    iv3    |  iv4  |  iv5 | 

where H indicates header fields and hv indicates the header value and I indicates the item and iv indicates the item value..

I want to achieve that...I am not able to do that .

Suvajit..

1 ACCEPTED SOLUTION

former_member404244
Active Contributor
0 Kudos

Hi,

You can declare a structre like this assuming you will be having 5 fields in the item level.. You need to take the highest length for that particular column. for example if IV1 is having 20 char and H1 with 15,HV1 with 10 and I1 18 charcaters then take for column one you need to take the length 20 as specified below.Similarly for rest of the 4 columns to need to check and declare . The below code is just for yor reference.


TYPES : BEGIN OF t_temp,
rec_type(1)  TYPE c,   "Record Type
        f1(20)       TYPE c,   "First field
        f2(40)       TYPE c ,  "Second field
        f3(20)       TYPE c ,  "Third field
        f4(20)       TYPE c ,  "Fourth field
        f5(40)       TYPE c ,  "Fifth field
    END OF T_TEMP.

  *    Internal table used to upload data from flat file
data :     i_temp          TYPE STANDARD TABLE OF t_temp.      
now use GUI_UPLOAD fm to I_temp internal table.

now data is tehre in the internal table.. Now define 4 intenal tables for header and line items.
Loop the I_TEMP internal table and based on rec_type you fill the values and append to the 4 internal tables.

Regards,

Nagaraj

5 REPLIES 5

former_member404244
Active Contributor
0 Kudos

Hi,

You can declare a structre like this assuming you will be having 5 fields in the item level.. You need to take the highest length for that particular column. for example if IV1 is having 20 char and H1 with 15,HV1 with 10 and I1 18 charcaters then take for column one you need to take the length 20 as specified below.Similarly for rest of the 4 columns to need to check and declare . The below code is just for yor reference.


TYPES : BEGIN OF t_temp,
rec_type(1)  TYPE c,   "Record Type
        f1(20)       TYPE c,   "First field
        f2(40)       TYPE c ,  "Second field
        f3(20)       TYPE c ,  "Third field
        f4(20)       TYPE c ,  "Fourth field
        f5(40)       TYPE c ,  "Fifth field
    END OF T_TEMP.

  *    Internal table used to upload data from flat file
data :     i_temp          TYPE STANDARD TABLE OF t_temp.      
now use GUI_UPLOAD fm to I_temp internal table.

now data is tehre in the internal table.. Now define 4 intenal tables for header and line items.
Loop the I_TEMP internal table and based on rec_type you fill the values and append to the 4 internal tables.

Regards,

Nagaraj

matt
Active Contributor
0 Kudos

Why are you not able to do it - it seems a very simple programming task to me. What problems did you encounter when you tried it?

matt

Former Member
0 Kudos

The header of the item is coming in the next line no problem with that but it is coming under the column of the last one of the header column...

like this...


Transaction Type	Error Threshold	Password Generation                                                                                
100	0	welcome                                                                                
Transaction Type	First Name	Middle Name	Last Name	Employee ID	Login ID	
							300	Concur	Interface	Test3	00080215				en_US	

when the item level header is coming additional spaces are coming before...how to truncate that,,,I want the Item Level text come also from the beginning...

I have used final internal table instead of using seperate internal tables.....

Former Member
0 Kudos

Create a internal table with only one field. The field type could be C(255) or String. Put code similar to :

Loop at I_Hdr.
   Concatenate I_HDR-F1 I_HDR-F2 I_HDR-F3 I_HDR-F4 into I_Final-line separated by '|'.
   Append I_FINAL.
   Loop at I_LINE where Key = I_HDR-KEY.
   Concatenate I_LINE-F1 I_LINE-F2 I_LINE-F3 I_LINE-F4 I_LINE-F5 into I_Final-line separated by '|'.
   Append I_FINAL.
   Endloop
EndLoop

After this you can download I_FINAL.

Former Member
0 Kudos

This message was moderated.