Skip to Content

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

Dear Frds,

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

Fetching values from work area to internal table.

After that i m Strucked.

Pls Help me out.

Kabil

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    Posted on Jul 18, 2014 at 11:36 AM

    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. Flow Logic - User Command

    1. Structure Declaration

    ZCALC Table Structure

    ZSEMI Table Structure


    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_calc TYPE TABLE OF ty_calc, "Internal Table
    wa_calc TYPE ty_calc. "Work Area

    "Data Declaration - ZSEMI
    DATA: it_semi TYPE 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

    3. Flow Logic - User Command


    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 PBO

    MODULE tbl_calc_change_tc_attr OUTPUT.
    "Retrive the value from Database Table
    SELECT matnr
    werks
    maktx
    FROM zcalc
    INTO TABLE it_calc.

    DESCRIBE TABLE it_calc LINES tbl_calc-lines.
    ENDMODULE. "TBL_CALC_CHANGE_TC_ATTR OUTPUT


    Program written in User command

    MODULE user_command_0100 INPUT.

    IF sy-ucomm = 'SAVE'.

    LOOP AT it_calc INTO 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_semi TO it_semi.
    ENDLOOP.

    "Update Ztable
    MODIFY zsemi FROM TABLE it_semi.
    COMMIT WORK.
    ENDIF.
    ENDMODULE. " USER_COMMAND_0100 INPUT

    Output:

    The following values retrieved from ZCALC Table to Table Control. MATNR is a mentioned as Key Field in ZCALC Table, so it is disabled in Table Control. If save button is clicked, the values will store in ZSEMI Table as shown below.

    Before save button clicked - ZSEMI Table

    After save button is clicked - ZSEMI Table

    Finally the value is stored in ZSEMI Table.

    Regards

    Rajkumar Narasimman


    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 14, 2014 at 07:30 AM

    Hi Kapil,

    Using Insert or modify statement you can update the the ztable.

    for eg.

    INSERT INTO MARA VALUES WA_MARA.

    MODIFY MARA FROM WA_MARA.

    When you are working with table control you will declare the loop statement in PBO & PAI.

    So PAI loop will take care of updating multiple line items in to Ztable. so in that loop you have to use the above statements.

    Regards,

    Sheshu

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 14, 2014 at 07:35 AM

    HI Kabil,

    You need this statement:

    MODIFY itab FROM wa TRANSPORTING col WHERE comparison. it will modify mutiple lines of itab.

    the 'MODIFY MARA FROM WA_MARA.' will only modify the first line which is meet the key field.

    Regards,

    Archer

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 15, 2014 at 07:04 AM

    Hi Kabil,

    let us say, you have collected data into internal table lt_my_data.

    Now, update the data as below

    modify ZTABLE from table lt_my_data.

    Hope this helps you.

    Regards,

    Rama

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.