Quantcast
Viewing all articles
Browse latest Browse all 8627

Re: How to update the multiple line items which in table control to Ztable

Hi Kabil,

  I created one simple example in table control, which is same as your requirement. Please find the steps below for Table control.

  1. Structure Declaration
  2. Screen creation
  3. User Control

 

Image may be NSFW.
Clik here to view.
2014-07-18_16-26-39.jpg

1. Structure Declaration

 

ZCALC Table Structure

Image may be NSFW.
Clik here to view.
2014-07-18_16-31-18.jpg

ZSEMI Table Structure

Image may be NSFW.
Clik here to view.
2014-07-18_16-32-11.jpg


Top Declarations

PROGRAM  zscreen_06.

"Structure Declaration
TYPES: BEGIN OF ty_calc,
        matnr
TYPE zcalc-matnr,
        werks
TYPE zcalc-werks,
        maktx
TYPE zcalc-maktx,
     
END OF ty_calc.

"Data Declaration - ZCALC
DATA: it_calcTYPE TABLE OF ty_calc,  "Internal Table
      wa_calc
TYPE ty_calc.           "Work Area

"Data Declaration - ZSEMI
DATA: it_semiTYPE TABLE OF zsemi,    "Internal Table
      wa_semi
TYPE 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.
2014-07-18_16-53-50.jpg


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.
2014-07-18_15-59-56.jpg

 

Before save button clicked - ZSEMI Table

Image may be NSFW.
Clik here to view.
2014-07-18_15-57-58.jpg

After save button is clicked - ZSEMI Table

Image may be NSFW.
Clik here to view.
2014-07-18_15-58-19.jpg

Finally the value is stored in ZSEMI Table.

 

Regards

 

Rajkumar Narasimman


Viewing all articles
Browse latest Browse all 8627

Trending Articles