Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how to fetch data from database table based on table control values

Former Member
0 Likes
6,971

hi experts,

             i have developed table control in which 5 columns are there,what i need is that when i enter values for example first column is matnr,when i entered matnr no  in first column and i have pressed enter button.it has to select all values of mara table based on first column matnr no and fill table control.

anyone can help me for the same.

regards,

vinodh

11 REPLIES 11
Read only

Former Member
0 Likes
3,941

Hi

You can develop a module in PAI process in order to fill your table control, this module should be triggered as soon as the value of the first field is changed.

Max

Read only

Former Member
0 Likes
3,941

In the PAI module, do the following

PROCESS AFTER INPUT.

  LOOP WITH CONTROL T_C.

    MODULE update_table.

  ENDLOOP.

module update_table INPUT.

read table itab index t_c-current_line.

* Get all database values based on column 1

select ..... where col1 = itab-col1.

* Set all other values in the internal table work area.

itab-col2 =

itab-col3 =

modify itab index t_c-current_line.  

ENDMODULE.

Read only

0 Likes
3,941

hi,

  i wil try and let u now.

Read only

0 Likes
3,941

hi,

the following error is coming,'The addition "WITH CONTROL TBC_9003" is missing in a LOOP in PBO.'

Read only

0 Likes
3,941

IN the loop that you have given in the PBO, you probably have not give the reference to table control. In the PBO, verify that loop statements.

process before output.

Loop at itab with control tbc_9003.

endloop.

Also, a small correction in the above code, you need to loop at the internal table in the PAI, not the control.

PROCESS AFTER INPUT.

  LOOP at itab.

    MODULE update_table.

  ENDLOOP.

Read only

0 Likes
3,941

Vinodh,

Two steps are needed for your requirement:

1) Make use of the TC_MODIFY module itself to fetch other values .

MODULE TC6000_MODIFY INPUT.


   "FETCH OTHER VALUES FOR TABLE CONTROL FIELDS HERE


        MODIFY D1 INDEX TC6000-CURRENT_LINE.

        if sy-subrc <> 0.

          insert d1 INDEX TC6000-CURRENT_LINE.

        endif.

ENDMODULE.                    "TC6000_MODIFY INPUT

2) Set the number of editable lines in the table control.

Regards.

Read only

0 Likes
3,941

hi,

this is my code for pbo.

PROCESS BEFORE OUTPUT.

*&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'TBC_9003'

  

*&SPWIZARD: MODULE TBC_9003_CHANGE_COL_ATTR.

   LOOP AT   IT_ZPP_MPO

        INTO WA_ZPP_MPO

        WITH CONTROL TBC_9003

        CURSOR TBC_9003-CURRENT_LINE.

*&SPWIZARD:   MODULE TBC_9003_CHANGE_FIELD_ATTR

   ENDLOOP.

  

  MODULE STATUS_9002.

*

PROCESS AFTER INPUT.

   LOOP WITH CONTROL TBC_9003.

     MODULE update_table.

   ENDLOOP.

   module update_table INPUT.

     read table it_zpp_mpo INTO wa_zpp_mpo index TBC_9003-current_line.

     SELECT * FROM ZPP_MPO_MASTER1 INTO it_zpp_mpo WHERE matnr =

wa_zpp_mpo-matnr.

       ZPP_MPO_MASTER1-matnr = wa_zpp_mpo-matnr.

       modify it_zpp_mpo FROM wa_zpp_mpo index TBC_9003-current_line.

       endmodule.

*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TBC_9003'

   LOOP AT IT_ZPP_MPO.

     CHAIN.

       FIELD WA_ZPP_MPO-MATNR.

       FIELD WA_ZPP_MPO-MCARDNO.

       FIELD WA_ZPP_MPO-ZFQTY.

       FIELD WA_ZPP_MPO-REMAKS.

       FIELD WA_ZPP_MPO-TOTAL.

       MODULE TBC_9003_MODIFY ON CHAIN-REQUEST.

     ENDCHAIN.

     FIELD WA_ZPP_MPO-ZAQTY

       MODULE TBC_9003_MARK ON REQUEST.

   ENDLOOP.

*&SPWIZARD: MODULE TBC_9003_CHANGE_TC_ATTR.

*&SPWIZARD: MODULE TBC_9003_CHANGE_COL_ATTR.

  MODULE USER_COMMAND_9002.

Read only

0 Likes
3,941

PROCESS AFTER INPUT.

   LOOP WITH CONTROL TBC_9003.

     MODULE update_table.

   ENDLOOP.

    LOOP AT IT_ZPP_MPO  .

     CHAIN.

       FIELD WA_ZPP_MPO-MATNR.

       FIELD WA_ZPP_MPO-MCARDNO.

       FIELD WA_ZPP_MPO-ZFQTY.

       FIELD WA_ZPP_MPO-REMAKS.

       FIELD WA_ZPP_MPO-TOTAL.

       MODULE TBC_9003_MODIFY ON CHAIN-REQUEST.

     ENDCHAIN.

        FIELD WA_ZPP_MPO-ZAQTY

       MODULE TBC_9003_MARK ON REQUEST.

      MODULE update_table.

   ENDLOOP.

module update_table INPUT

     read table it_zpp_mpo INTO wa_zpp_mpo index TBC_9003-current_line.

*  Create another temperoray work area wa_zpp_mpo_tmp.

     SELECT single * FROM ZPP_MPO_MASTER1 INTO wa_zpp_mpo_tmp

              WHERE matnr = wa_zpp_mpo-matnr. 

* Move all the required fields

       WA_ZPP_MPO-MCARDNO = wa_zpp_mpo_tmp-mcardno.

       FIELD WA_ZPP_MPO-ZFQTY = wa_zpp_mpo_tmp-zfqty.

       FIELD WA_ZPP_MPO-REMAKS = wa_zpp_mpo_tmp-remaks

       modify it_zpp_mpo FROM wa_zpp_mpo index TBC_9003-current_line.

      endmodule.

Read only

0 Likes
3,941

hi susan,

            i have included your but still not solved,i debug the program the internal table is not fetching any data.

Read only

0 Likes
3,941

Hi

It seems you're using the same workarea (wa_zpp_mpo) for the dynpro field and the internal table, so the data can  be overwritten, you should use a different workarea while reading the internal table and read it after getting the data you need

module update_table INPUT.

     read table it_zpp_mpo INTO wa_zpp_mpo index TBC_9003-current_line.

*  Create another temperoray work area wa_zpp_mpo_tmp.

     SELECT single * FROM ZPP_MPO_MASTER1 INTO wa_zpp_mpo_tmp

              WHERE matnr = wa_zpp_mpo-matnr.

     if sy-subrc = 0.

      clear wa_zpp_mpo_tmp.

     endif.

    

   

     read table it_zpp_mpo INTO wa_zpp_mpo_tmp_2 index TBC_9003-current_line.

     read_rc = sy-subrc

    if read_rc <> 0.

       clear wa_zpp_mpo_tmp_2.

    endif.

   wa_zpp_mpo_tmp_2-matnr = wa_zpp_mpo-matnr.  

    wa_zpp_mpo = wa_zpp_mpo_tmp_2.


     WA_ZPP_MPO-MCARDNO = wa_zpp_mpo_tmp-mcardno.

     WA_ZPP_MPO-ZFQTY = wa_zpp_mpo_tmp-zfqty.

     WA_ZPP_MPO-REMAKS = wa_zpp_mpo_tmp-remaks

   

    if read_rc = 0.

       modify it_zpp_mpo FROM wa_zpp_mpo index TBC_9003-current_line.

    else.

      append wa_zpp_mpo to it_zpp_mpo.

    endif

Max

Read only

Former Member
0 Likes
3,941

HI Vinodh,

Try this.