Hi Kabil,
I created one simple example in table control, which is same as your requirement. Please find the steps below for Table control.
- Structure Declaration
- Screen creation
- User Control
Image may be NSFW.
Clik here to view.
1. Structure Declaration
ZCALC Table Structure
Image may be NSFW.
Clik here to view.
ZSEMI Table Structure
Image may be NSFW.
Clik here to view.
Top Declarations
PROGRAM zscreen_06.
"Structure Declaration
TYPES: BEGIN OF ty_calc,
matnrTYPE zcalc-matnr,
werksTYPE zcalc-werks,
maktxTYPE zcalc-maktx,
END OF ty_calc.
"Data Declaration - ZCALC
DATA: it_calcTYPE TABLE OF ty_calc, "Internal Table
wa_calcTYPE ty_calc. "Work Area
"Data Declaration - ZSEMI
DATA: it_semiTYPE TABLE OF zsemi, "Internal Table
wa_semiTYPE zsemi. "Work Area
"Include for Data Declarations
INCLUDE zscreen_06_top.
"Include for PBO
INCLUDE zscreen_06_pbo.
"Include for PAI
INCLUDE zscreen_06_pai.
"Include for Subroutine
INCLUDE zscreen_06_f01.
2. Screen Creation
Create a Screen 0100.
Create a Table control using Internal Table IT_CALC and Work Area WA_CALC.
Instead of creating PF Status, for basic example, I have created a button 'SAVE' and the function code also mentioned as 'SAVE'.
Screen 0100
Image may be NSFW.
Clik here to view.
Program written in Flow Logic
PROCESS BEFORE OUTPUT.
*&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'TBL_CALC'
MODULE TBL_CALC_CHANGE_TC_ATTR.
*&SPWIZARD: MODULE TBL_CALC_CHANGE_COL_ATTR.
LOOP AT IT_CALC
INTO WA_CALC
WITH CONTROL TBL_CALC
CURSOR TBL_CALC-CURRENT_LINE.
MODULE TBL_CALC_GET_LINES.
*&SPWIZARD: MODULE TBL_CALC_CHANGE_FIELD_ATTR
ENDLOOP.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TBL_CALC'
LOOP AT IT_CALC.
CHAIN.
FIELD WA_CALC-MATNR.
FIELD WA_CALC-WERKS.
FIELD WA_CALC-MAKTX.
ENDCHAIN.
ENDLOOP.
MODULE TBL_CALC_USER_COMMAND.
MODULE USER_COMMAND_0100.
Program written in User command
MODULE user_command_0100 INPUT.
IF sy-ucomm= 'SAVE'.
LOOP AT it_calcINTO wa_calc.
"Assign the values to Work Area
wa_semi-mandt= sy-mandt.
wa_semi-matnr= wa_calc-matnr.
wa_semi-werks= wa_calc-werks.
wa_semi-maktx= wa_calc-maktx.
"Append the Work Area to Internal Table
APPEND wa_semiTO it_semi.
ENDLOOP.
"Update Ztable
MODIFY zsemiFROM TABLE it_semi.
COMMIT WORK.
ENDIF.
ENDMODULE. " USER_COMMAND_0100 INPUT
Output:
Image may be NSFW.
Clik here to view.
Before save button clicked - ZSEMI Table
Image may be NSFW.
Clik here to view.
After save button is clicked - ZSEMI Table
Image may be NSFW.
Clik here to view.
Finally the value is stored in ZSEMI Table.
Regards
Rajkumar Narasimman