Application Development and Automation 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: 
Read only

Internal Table operation - columns to rows

former_member227140
Active Participant
0 Likes
1,420


Hi Expert ,

I am getting my data into one internal table after processing through a Function module.

please find my output internal table as below

ATINNATNAMATWRT
0000001012SEG_ID           1
0000001011SEG_QTY        20
0000001013SEG_WDTH        48
0000001010SEG_LGTH        144
0000001012SEG_ID          2
0000001011SEG_QTY        15
0000001013SEG_WDTH        48
0000001010SEG_LGTH        136

Now I want to convert it to a internal table wherein there will be 4 columns SEG_ID , SEG_QTY , SEG_WDTH , SEG_LNGTH.

    20
SEG_IDSEG_QTYSEG_WDTHSEG_LGTH
               1              48                        144
               2   15              48                        136

in this case I am sure columns will always be 4 and rows will be 3 only .

how I can achieve this . I am coding it inside a smartform where in I will print this table on smartform.

can you expert please let me know how can I achieve this???

1 ACCEPTED SOLUTION
Read only

rosenberg_eitan
Active Contributor
0 Likes
1,385

Hi,

If you need a print out have a look here:

Regards.

Hi,

If you need a print out have a look here:

Regards.

10 REPLIES 10
Read only

Former Member
0 Likes
1,385

Check this document.

Read only

0 Likes
1,385

is there any alternate way???

in my form its sure that I will have 4 columns , do I need to do everything what is mentioned in the document to create a internal table as required by me???


Read only

rosenberg_eitan
Active Contributor
0 Likes
1,386

Hi,

If you need a print out have a look here:

Regards.

Read only

0 Likes
1,385

columns are fixed and they are 4 . SEG_ID , SEG_QTY , SEG_WDTH , SEG_LNGTH. this I will manage by create a table in smartform and a line type to header with these 4 columns.

ATINNATNAMATWRT
0000001012SEG_ID           1
0000001011SEG_QTY        20
0000001013SEG_WDTH        48
0000001010SEG_LGTH        144
0000001012SEG_ID          2
0000001011SEG_QTY        15
0000001013SEG_WDTH        48
0000001010SEG_LGTH        136

I am getting above table as output of some function module.

I need to move this to a internal table with above 4 columns and the values in field ATWRT as rows of that internal table.

1           20               48           144

2           15               48           136

do I need to use dynamic table concept here , I don't think so cause my columns are always fixed as 4

Read only

0 Likes
1,384

Hi,

Maybe the name of the article is misleading .

There is no use of RTTS in the program or SmartForm.

Full source is included. have a look.

Regards.

Read only

0 Likes
1,384

Hi Abhijeet,

If the columns are already known, then you definitely dont have to go for dynamic table. You can apply the suitable logic to move the data from the input table to output table.

For eg, if the structure of your input and output table is as follows.

TYPES : BEGIN OF input,
          atinn TYPE atinn,
          atnam TYPE atnam,
         atwrt TYPE atwrt,
   END OF input.

TYPES : BEGIN OF output,
         seg_id TYPE char30,
         seg_qty TYPE char30,
         seg_wdth TYPE char30,
         seg_lgth TYPE char30,
   END OF output.


Once you fill the input table with the values, move values for each characteristic to the output table. Suppose, it_ip and it_op are the input and output internal tables and wa_ip and wa_op the corresponding work areas.

Assuming there would be only as many rows as there are values for the characteristic seg_id, you could use the following logic.



CLEAR : wa_ip, wa_op.
LOOP AT it_ip INTO wa_ip WHERE atinn = '0000001012'.
   wa_op-seg_id = wa_ip-atwrt.
   APPEND wa_op TO it_op.
   CLEAR : wa_ip, wa_op.
ENDLOOP.

CLEAR : wa_ip, wa_op.
lv_index = 1.
LOOP AT it_ip INTO wa_ip WHERE atinn = '0000001011'.
   wa_op-seg_qty = wa_ip-atwrt.
   MODIFY it_op FROM wa_op INDEX lv_index TRANSPORTING seg_qty.
   CLEAR : wa_ip, wa_op.
   ADD 1 TO lv_index.
ENDLOOP.

CLEAR : wa_ip, wa_op.
lv_index = 1.
LOOP AT it_ip INTO wa_ip WHERE atinn = '0000001013'.
   wa_op-seg_wdth = wa_ip-atwrt.
   MODIFY it_op FROM wa_op INDEX lv_index TRANSPORTING seg_wdth.
   CLEAR : wa_ip, wa_op.
   ADD 1 TO lv_index.
ENDLOOP.

CLEAR : wa_ip, wa_op.
lv_index = 1.
LOOP AT it_ip INTO wa_ip WHERE atinn = '0000001010'.
   wa_op-seg_lgth = wa_ip-atwrt.
   MODIFY it_op FROM wa_op INDEX lv_index TRANSPORTING seg_lgth.
   CLEAR : wa_ip, wa_op.
   ADD 1 TO lv_index.
ENDLOOP.

Read only

0 Likes
1,384

Hi Susmitha ,

Thanks for your answer. though I have resolved this using ASSIGN COMPONENT OF on same day. but I have tried your solution and its working too. thanks for help. marking your answer as correct .

Thanks Eitan too

Read only

0 Likes
1,384

Have fun...

Read only

0 Likes
1,384

Hello.

I created a new page format X_144_48 ( ABAP/4 list: At least 144 rows by 48 columns) using t-code SPAD.

Now I want to link this newly created page format with my default printer(LP01)..?

How it can be done.?

Please guide me...

Regards,

Junaid

Read only

0 Likes
1,384

Dear All,

Please help me out from this problem..!!

Waiting for your response.

Regards,

Junaid