2014 Nov 05 3:32 AM
I am working on a table control.
Here's the part of the logic.
LOOP AT gt_xxx_scr. "internal table related to the table control
MODULE modify_data.
ENDLOOP.
MODULE modify_data is used to modify or append when the user makes some changes on TC.
The TC displayed correctly at the first place.
But after gt_xxx_scr was changed but make NO change on the TC,
the logic did go into the LOOP that makes the TC displayed incorrectly.
I think that it should not go into the loop when no change is made on the TC.
I am working on a table control.
Here's the part of the logic.
LOOP AT gt_xxx_scr. "internal table related to the table control
MODULE modify_data.
ENDLOOP.
MODULE modify_data is used to modify or append when the user makes some changes on TC.
The TC displayed correctly at the first place.
But after gt_xxx_scr was changed but make NO change on the TC,
the logic did go into the LOOP that makes the TC displayed incorrectly.
I think that it should not go into the loop when no change is made on the TC.
2014 Nov 05 3:59 AM
Hi Ming Yu,
For a table control, if you change or not it will always go into the loop when there is some user action that occurs and that is how module pool program works. So you need to do the appending and modifying data in a proper way.
Thanks,
2014 Nov 05 5:43 AM
For the first time that internal table gets the content, the system doesn't go into the LOOP logic.
And I have tried before(as far as I remembered), if you don't make any change on TC(like enter some values onto the TC), the logic will skip the LOOP.
2014 Nov 05 4:28 AM
Hi
in module which you hae writen for midiying the TC write proper logic.
MODIFY t_tc FROM w_tc INDEX tbc-current_line [TRANSPORTING <f1> <f2> .. ].
IF sy-subrc <> 0.
APPEND w_tc TO t_tc.
ENDIF.
regards
laxman
2014 Nov 05 5:46 AM
Yes, I write this in the MODULE modify_data.
But the problem is that when internal table's content is changed, the value of 't_tc' is last internal table's value.
That makes modify and append work incorrectly.
2014 Nov 05 5:54 AM
Perhaps you need to refresh the screen. Is it for some ALV module pool program or generic one. If its ALV module pool program then we do have system field to refresh the screen.
2014 Nov 05 5:59 AM
It's just a common Module Pool program.
Which confuses me is, after 'LOOP AT gt_xxx_scr'
the work area is not the first record of current gt_xxx_scr, but a certain record of last internal table's.
2014 Nov 05 6:20 AM
The loop at PAI is only loop through the records that you are currently seeing in table control.
So this is mandatory that you must specify index while modifying.
MODIFY it FROM wa INDEX tc-current_line.
IF sy-subrc <> 0.
APPEND wa TO it.
ENDIF.
2014 Nov 05 6:27 AM
Yes, I do specify the index.
But the point is, the internal table has already been changed and it doesn't need to go into the LOOP.
If it goes into the LOOP, and execute:
MODIFY it FROM wa INDEX tc-current_line.
IF sy-subrc <> 0.
APPEND wa TO it.
ENDIF.
This will change the content of the internal table and make display wrong after PBO.
2014 Nov 05 6:53 AM
So rather than modifying through table control you have another code for it?
Keep those piece of code after Loop... endloop.
And if you don't want this..
MODIFY it FROM wa INDEX tc-current_line.
IF sy-subrc <> 0.
APPEND wa TO it.
ENDIF.
comment them..
2014 Nov 06 6:58 AM
Hi, I have worked this out.
Actually, the change of the internal table should be run after LOOP.
Just like:
LOOP AT gt_xxx_scr. "internal table related to the table control
MODULE modify_data.
ENDLOOP.
MODULE get_data_to_internal_table.
The LOOP here is different from common ones, it reads the line content from the table control rather than reads from the internal table.
Anyway, thank you for your help.
2014 Nov 06 7:00 AM
By the way, you can either write ' get_data_to_internal_table.' in PAI or in PBO, in this case, it is triggered by a button, so I wrote this in PAI.
2014 Nov 06 8:49 AM
May i ask, why do you want a additional module for modifying internal table? What is the purpose of table control?
Normally the records seeing in table control can be manipulated from loop at PBO(before display)
or loop at PAI(after display, to catch the changes made by user).
2014 Nov 06 9:17 AM
Hi,
Because there is a search criteria, every time the search criteria changes, the internal table should be changed also no matter if table control is changed or not.
It's like a RESET function, not just Modify or Add rows in the table control.
2014 Nov 06 10:32 AM
replace the loop inside MODULE get_data_to_internal_table with ....
do.
read it_tab into wa_tab index sy-index.
if sy-subrc = 0.
*****code to reset
else.
exit.
endif.
enddo.
2014 Nov 07 1:22 AM
But editing table control is also needed, if sy-subrc = 4 in your case, you don't know the new record is from the new internal table or it is just a new row from table control entered by a user.
2014 Nov 05 6:11 AM
2014 Nov 07 3:55 AM
Hi,
in screen use workarea.. then if only changes are there go inside MODULE IT_CARDLIST_MODIFY ON CHAIN-REQUEST
LOOP AT IT_CARD_LIST.
CHAIN.
FIELD WA_CARD_LIST-CB.
FIELD WA_CARD_LIST-YMTCARD.
FIELD WA_CARD_LIST-YMTNO.
FIELD WA_CARD_LIST-MATNR.
FIELD WA_CARD_LIST-MAKTX.
FIELD WA_CARD_LIST-CHARG.
MODULE IT_CARDLIST_MODIFY ON CHAIN-REQUEST.
endchain.
ENDLOOP.
In PAI
MODULE IT_CARDLIST_MODIFY INPUT.
*** if need condition add here before modify
MODIFY IT_CARD_LIST
FROM WA_CARD_LIST
INDEX IT_CARDLIST-CURRENT_LINE.
ENDMODULE.
Is this u want.
2014 Nov 07 6:44 AM
Hi, does it mean only if table control has been changed, then go inside the LOOP?
But it seems that it still has some problems, if you change the internal table and table control both, yet you don't want LOOP is executed.
2014 Nov 07 8:30 AM
Hi,
if table control has been changed only go inside the MODULE IT_CARDLIST_MODIFY ON CHAIN-REQUEST. otherwise just go through the loop and nothing will be updated.
can you explain ur problem with coding or explain more ??
2014 Nov 07 8:59 AM
There is some search criteria and a button on the scree and after search criteria is changed and button is clicked, data is fetched from the database and go into the internal table.
This logic, as far as I consider, has nothing to do with the LOOP/chain.
2014 Nov 07 9:40 AM
I thought you want to update table control value ...
can you add screen shot?
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |