2014 May 08 10:12 AM
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
| ATINN | ATNAM | ATWRT |
|---|---|---|
| 0000001012 | SEG_ID | 1 |
| 0000001011 | SEG_QTY | 20 |
| 0000001013 | SEG_WDTH | 48 |
| 0000001010 | SEG_LGTH | 144 |
| 0000001012 | SEG_ID | 2 |
| 0000001011 | SEG_QTY | 15 |
| 0000001013 | SEG_WDTH | 48 |
| 0000001010 | SEG_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.
| SEG_ID | SEG_QTY | SEG_WDTH | SEG_LGTH |
|---|---|---|---|
| 1 | 2048 | 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???
2014 May 08 12:59 PM
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.
2014 May 08 10:28 AM
2014 May 08 12:50 PM
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???
2014 May 08 12:59 PM
2014 May 08 1:24 PM
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.
| ATINN | ATNAM | ATWRT |
|---|---|---|
| 0000001012 | SEG_ID | 1 |
| 0000001011 | SEG_QTY | 20 |
| 0000001013 | SEG_WDTH | 48 |
| 0000001010 | SEG_LGTH | 144 |
| 0000001012 | SEG_ID | 2 |
| 0000001011 | SEG_QTY | 15 |
| 0000001013 | SEG_WDTH | 48 |
| 0000001010 | SEG_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
2014 May 08 2:26 PM
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.
2014 May 11 7:14 AM
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.
2014 May 12 11:15 AM
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
2014 May 12 12:12 PM
2014 Jun 05 7:31 AM
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
2014 Jun 06 6:47 AM
Dear All,
Please help me out from this problem..!!
Waiting for your response.
Regards,
Junaid
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |