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

Automatic table control field insertion

Former Member
0 Likes
1,663

Hi Experts,

I am creating a dailog program. There are 2 screens in this program. In the first screen there is one I/o for Vendor number. Now when I enter a vendor number in first screen and press create button it takes me to the second screen of table control.

Now my requirement is that the vendor number and corresponding vendor name automatically comes  to the second screen inside the respective column of table control.

Sure reward for the right answer.

Thanks in advance,

Aakash

1 ACCEPTED SOLUTION
Read only

ipravir
Active Contributor
0 Likes
1,616

Hi,

In 1st screen, one file for Vendor - like ---GV_LIFNR.

in 2nd screen Table control like ( Vendor, Name, ...etc).

After Press button in 1st screen, in PAI.

Select single NAME from LFA1 into gv_name where lifnr eq GV_lifnr.

In PBO of 2nd screen.

Loop at Table_control_table into wa with table Control_obj.

     wa-lifnr = GV_LIFNR.

     wa-name = gv_name.

Endloop.

Like this, vendor name and number will come by default for all line of table control.

Regards,

Praveer.

15 REPLIES 15
Read only

Former Member
0 Likes
1,616

I am sorry . I forgot to mention that there are several other fields also in that table control and when i save the data entered in that table control , it goes into a ztable.

Please let me know if you need some other details also.

Thank you

Read only

0 Likes
1,616

If the screen-field name for vendor # is same in both the screens, I think it should automatically populate the values from screen 1 to screen 2.

Thanks,

Vikram.M

Read only

0 Likes
1,616

the screen field name for vendor number cant be same because in table control that field refers to ztable where the data is going to be stored.

However, i tried the below solution but it is also not working. Please tell me where i am doing wrong.

Flow logic for 1st screen:-

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

*

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0100.

MODULE VENDOR_DATA.

Flow logic for 2nd screen:-

PROCESS BEFORE OUTPUT.

MODULE VENDOR.

LOOP AT IT_ZTASK WITH CONTROL DATA.

MODULE STATUS_0101.

ENDLOOP.

*

PROCESS AFTER INPUT.

LOOP AT IT_ZTASK.

MODULE USER_COMMAND_0101.

ENDLOOP.

here is the coding of two added module ie. MODULE VENDOR_DATA AND MODULE VENDOR

MODULE VENDOR_DATA INPUT.

SELECT  LIFNR NAME1 FROM LFA1 INTO TABLE IT_LFA1 WHERE LIFNR =

LFA1-LIFNR.

SELECT LIFNR INTAD FROM LFB1 INTO TABLE IT_LFB1 WHERE LIFNR =

LFA1-LIFNR.

SORT IT_LFA1 BY LIFNR.

SORT IT_LFB1 BY LIFNR.

LOOP AT IT_LFA1 INTO WA_LFA1.

READ TABLE IT_LFB1 INTO WA_LFB1 WITH KEY LIFNR = IT_LFA1-LIFNR.

WA_OUT-LIFNR = IT_LFA1-LIFNR.

WA_OUT-NAME1 = IT_LFA1-NAME1.

WA_OUT-INTAD = IT_LFB1-INTAD.

APPEND WA_OUT TO IT_OUT.

ENDLOOP.

ENDMODULE.

MODULE VENDOR OUTPUT.

ZTASK-VENDOR_NUMBER = WA_OUT-LIFNR.

ZTASK-VENDOR_NAME = WA_OUT-NAME1.

ZTASK-TERMS_N_COND = WA_OUT-INTAD.

ENDMODULE.

Read only

0 Likes
1,616

Hi,

You dont have to do all this.

Screen 1001:

PBO.

PAI.

Module Vendor data.

Module Vendor_data.

SELECT  LIFNR NAME1 FROM LFA1 INTO TABLE IT_LFA1 WHERE LIFNR =

LFA1-LIFNR.

SELECT LIFNR INTAD FROM LFB1 INTO TABLE IT_LFB1 WHERE LIFNR =

LFA1-LIFNR.

SORT IT_LFA1 BY LIFNR.

SORT IT_LFB1 BY LIFNR.

LOOP AT IT_LFA1 INTO WA_LFA1.

READ TABLE IT_LFB1 INTO WA_LFB1 WITH KEY LIFNR = IT_LFA1-LIFNR.

WA_OUT-LIFNR = IT_LFA1-LIFNR.

WA_OUT-NAME1 = IT_LFA1-NAME1.

WA_OUT-INTAD = IT_LFB1-INTAD.

APPEND WA_OUT TO IT_OUT.

ENDLOOP.

Endmodule.

Screen 1002 . Your screen with table control.

PBO.

loop at   IT_OUT

        into IT_OUT

        with control t_tabl_ctrl

        cursor t_tabl_ctrl-current_line.

     module t_tabl_ctrl_get_lines.

*&SPWIZARD:   MODULE T_TABL_CTRL_CHANGE_FIELD_ATTR

   endloop.


PAI.


loop at it_out.

field wa_out-lifnr.

field wa_out-name1.

field wa_out-intad.

module insert on chain-request.

       module t_tabl_ctrl_modify on chain-request.


Endloop.


module insert input.

   read table it_out index t_tabl_ctrl-current_line transporting no fields.

   if sy-subrc <> 0.

     insert initial line into it_out index t_tabl_ctrl-current_line.

   endif.

endmodule.                 " INSERT  INPUT


module t_tabl_ctrl_modify input.

 

   modify it_out

     from wa_out

     index t_tabl_ctrl-current_line.

endmodule.



Here make sure that IT_OUT is defined as your internal table for the Table control and wa_out is work area for that.


Hope this helps.

Read only

0 Likes
1,616

Thanks for the reply gaurav but the solution u gave me is not working .

The data of 3 fields are not appearing inside the  table control field  as soon as enter that table control screen.

the data should be displayed there in the table control field.

Read only

ipravir
Active Contributor
0 Likes
1,617

Hi,

In 1st screen, one file for Vendor - like ---GV_LIFNR.

in 2nd screen Table control like ( Vendor, Name, ...etc).

After Press button in 1st screen, in PAI.

Select single NAME from LFA1 into gv_name where lifnr eq GV_lifnr.

In PBO of 2nd screen.

Loop at Table_control_table into wa with table Control_obj.

     wa-lifnr = GV_LIFNR.

     wa-name = gv_name.

Endloop.

Like this, vendor name and number will come by default for all line of table control.

Regards,

Praveer.

Read only

Former Member
0 Likes
1,616

I got those fields in the table control but now the problem is that all the rows of vendor number and vendor name are showing the same data .

FOR EX:- IF I enter vendor number 6 in the first screen then it fills all the rows of vendor number with vendor number 6 and corresponding vendor name in the vendor name field

I ONLY NEED IT TO SHOW IN THE FIRST ROW.

Read only

ipravir
Active Contributor
0 Likes
1,616

Ok..but change on existing logic.

Loop at Table_control_table into wa with table Control_obj.

     if sy-tabix eq 1.

          wa-lifnr = GV_LIFNR.

          wa-name = gv_name.

     endif.

Endloop.

You will get information, only in 1st row.

Regards,

Praveer.

Read only

Former Member
0 Likes
1,616

srry praveen but the solution u gave is not helping.

i am attaching my codes below u can take a look at them and then please help me out in correcting my codes.

thanks

aakash

Read only

ipravir
Active Contributor
0 Likes
1,616

Hi,

As you said.

I ONLY NEED IT TO SHOW IN THE FIRST ROW.


Means, you have to display vendor and name only in 1st row of table control?


So if you are updating information only for 1st row, then the same will display only for 1st row, the rest of the rows will be empty.


Or something else you are looking for, please provide you output information in excel format, so it could be easy to understand, what kind of output you are looking for.


Regard,

Praveer,

Read only

Former Member
0 Likes
1,616

Hi Praveen,

In the first screen , i enter a vendor number from vendor table( LFA1-LIFNR) . Now after i input the vendor number i enter the second screen ( SCREEN WITH TABLE CONTROL) . Here , there are several fields (YOU CAN LOOK AT THE ATTACHED FILE) . But in the vendor number and vendor name field i want the data to come from vendor table (LFA1) automatically .(( I dont need to enter vendor number and vendor name again in the table control screen). (the remaining fields of the table fields are to be filled manually). After that, when i save the data i should go to ztable (ZTASK).

This is the whole process.

Cannot attach Excel sheet.

Regards,

Aakash

Read only

ipravir
Active Contributor
0 Likes
1,616

If you want to add Vendor No and Name only in very 1st row of the Table control, then update your Internal table before comes to second screen with Vendor No and Name.

like

1st screen PAI.

Append LIFNR & Name to Final_internal_table.(Single Time)

in PBO.

only pass the information internal table information to table control.

Regards,

Praveer,

Read only

Former Member
0 Likes
1,616

I tried doing that in the starting but the internal table is not containing that data.

please check my codes in my third message.

Read only

ipravir
Active Contributor
0 Likes
1,616

Hi,

If you see, i ask you to do append single row in your table control.

As per your code, table control will contain only one row with respect to vendor, so that you can initialize at the PAI of 100 screen to append Vendor and Name and make a single records.

In sscreen 101, only one row will display.

Regards,

Praveer.

Read only

VenkatRamesh_V
Active Contributor
0 Likes
1,616

Hi,

TRY,

PROCESS AFTER INPUT.

CHAIN.

FIELD LFA1-LIFNR MODULE VENDOR ON CHAIN-REQUEST.

ENDCHAIN.

MODULE VENDOR.

SELECT  LIFNR NAME1 FROM LFA1 INTO TABLE IT_LFA1 WHERE LIFNR =

LFA1-LIFNR.

SELECT LIFNR INTAD FROM LFB1 INTO TABLE IT_LFB1 WHERE LIFNR =

LFA1-LIFNR.

SORT IT_LFA1 BY LIFNR.

SORT IT_LFB1 BY LIFNR.

LOOP AT IT_LFA1 INTO WA_LFA1.

READ TABLE IT_LFB1 INTO WA_LFB1 WITH KEY LIFNR = IT_LFA1-LIFNR.

WA_OUT-LIFNR = IT_LFA1-LIFNR.

WA_OUT-NAME1 = IT_LFA1-NAME1.

WA_OUT-INTAD = IT_LFB1-INTAD.

APPEND WA_OUT TO IT_OUT.

ENDLOOP.

CALL SCREEN 101.

ENDMODULE.

Hope it Helpful,

Regards,

Venkat.