Application Development 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: 

Table Control as Selection screen input grid

Former Member
0 Kudos

Hello Everyone,

I have to build a report where the selection screen has a 3 column table control (the fields are BKPF-BELNR, BUKRS & GJAHR)

The internal table corresponding to it has the same three fields -> bkpf-bukrs, belnr & gjahr.

The user should have the capability to enter data in the grid, scroll down to add more rows and then execute.

I would then be reading those documents from the BKPF table and performing some calculations.

The issue I have is how do I code the PBO & PAI for the table control to work properly.

Please explain with examples.

Thank you.

Regards,

Shipra

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos

Hi,

Did you have a look at demo programs DEMO_DYNPRO_TABCONT_LOOP and DEMO_DYNPRO_TABCONT_LOOP_AT ?

Sandra

13 REPLIES 13

Sandra_Rossi
Active Contributor
0 Kudos

Hi,

Did you have a look at demo programs DEMO_DYNPRO_TABCONT_LOOP and DEMO_DYNPRO_TABCONT_LOOP_AT ?

Sandra

0 Kudos

Thank you for the quick response Sandra.

I did understand how to do the PBO and PAI now using the demo program.

I still have a few problems. I created a menu for the program and did put function code CANCEL for the function key with the red cross in the standard toolbar. I also have the MODULE CANCEL AT EXIT-COMMAND. in my PAI

However, when i hit the red 'X' - i see that the program is always skipping the module to exit and goes to the loop ... endloop after the cancel module in the PAI event. How can I fix this and make the cancel to work.

Another issue that I have is the table control should be initially empty. Now i input some data in the rows that are showing in the table control without having to scroll. After this I hit the Next_page button - doing this, my table control becomes blank again. I am using the same code for navigating up and down just like in the demo program.

Please guide me.

Thank you very much for your help.

Regards,

Shipra

0 Kudos

Hi Shipra,

When you press Cancel, if it doesn't go to the MODULE AT EXIT-COMMAND, it means that either you didn't assign function type 'E' to your CANCEL function code (that is the most probable), or you didn't declare your module "CANCEL" as being PAI (MODULE CANCEL or MODULE CANCEL INPUT)

About the empty table control after having entered lines and pressed page down key, it doesn't look so strange as you want to display next page which is not entered yet... You should first check if the entered data has been successfully transferred to the internal table (during the loop in the PAI). If you think that data should be displayed, and it is not, then check in the PBO loop that the internal table data exists, and is correctly transferred to each line of the table control.

Sandra

0 Kudos

Thank you very much for that suggestion Sandra, I assigned the funtion type and it worked

I am trying to figure out the data handling now and would need some more help in the way. I will keep you posted.

Thank you very much,

Regards,

Shipra

0 Kudos

The sample program code for next page was not working as expected for my scenario. Hence, this is what i wrote:

WHEN 'NEXT_PAGE'.

TC_FIDOC-TOP_LINE = TC_FIDOC-TOP_LINE + LINES - 1.

LIMIT = FILL - LINES + 1.

  • this condition is only true when user goes from first to second page.

  • Without this, even if the user hits NEXT_PAGE, the scroll

  • bar appears but the table control still display the first page of data.

IF LIMIT < LINES.

TC_FIDOC-TOP_LINE = FILL .

ENDIF.

1. The table control is blank at the beginning.

2. user enters values in the fields and hits next.

3. the next blank page will be displayed with the last row as the top_line. That way the user will know what was the last line of data that they entered.

I think this solves my problem but I still have one small thing that I would like to incorporate in the program.

To go to a new page, I always have to click on the NEXT_PAGE button, the scroll bar does not scroll any further in that case. it only scrolls up to where i added the pages using the next_page button.

For ex:- if the user wants to use the scroll bar to add the new page, is that possible?

Thank you once again for all your help Sandra.

Regards,

Shipra

0 Kudos

Hi,

When the user uses the scroll bar, it does 2 things :

1) SAP automatically modifies TC_FIDOC-TOP_LINE according to the position of the scroll bar (personally I never define additional custom buttons to scroll)

2) SAP GUI simulates a Enter key so that the program can reload the table control from TC_FIDOC-TOP_LINE

Sandra

0 Kudos

Thank you Sandra.

My table control application is working well now.

I have one more question, some of the users have a larger screen and they would like to resize the table control to show more lines. I checked the resizing check boxes in the table control attribute but still the control cant be resized.

Do I need to do something else apart from this.

Thank you once again,

Shipra.

0 Kudos

Hi Shipra,

I think you must do the opposite : create a large area, and then the resize option will allow the SAP GUI to reduce (it's why we have the minimum height and width). It should be named "reduce" instead of "resize"

If it doesn't work, then maybe the issue is that it is contained in some non-resizable subscreens. In that case, you have to change the resize options (and check it at all upper levels). This is described in more details in a few notes, search the ones which contain the term "resizing".

Sandra

0 Kudos

Shipra - this is really a new question. Since you have already closed this one, it would be better if you would open a new one if you need any more follow up.

Rob

0 Kudos

Sorry Rob, thanks for the update.

Regards,

Shipra

madhu_vadlamani
Active Contributor
0 Kudos

This message was moderated.

raymond_giuseppi
Active Contributor
0 Kudos

In screen painte SE51 use the [Table Control Wizard|http://help.sap.com/saphelp_banking50/helpdata/en/6d/150d67da1011d3963800a0c94260a5/frameset.htm], then read, analyze and adapt the code to your requirement.

Regards,

Raymond

Former Member
0 Kudos

declare globally

CONTROLS: TABC TYPE TABLE VIEW USING SCREEN 100.

      • TABC IS NAME OF TABLE CONTROL****

TYPES:BEGIN OF TY_TABC.

INCLIDE STRUCTURE ________(GIVE THE STRU NAME).

DATA:S_FLAG TYPE C.

END OF TY_TABC.

**NOTE: THERE IS NO CHAIN FOR TY_TABC.

DATA:ITAB TYPE TABLE OF TY_TABC,

WA TYPE TY_TABC,

ITEMP TYPE TABLE OF YOUR STRCTURE,

WTEMP LIKE LINE OF ITEMP,

LINES TYPE SY-DBCNT.

IN PBO.

SELECT * FROM ___ INTO ITAB .

LINES = SY-DBCNT.

LOOP AT ITAB INTO WA CONTROL USING

TABC-CURRENT_LINE.

ENDLOOP.

IN PAI.

LOOP AT ITAB.

MODULE UPDATE.

ENDLOOP.

IN MODULE UPDATE.

CHECK WA-S_FLAG = 'X'.

MODIFY ITAB FROM WA TRANSPORTING

S_FLAG

WHERE KEY = WA-KEY.

MOVE-CORRESPONDING WA TO WTEMP.

APPEMD WTEMP TO ITEMP.

**KEY MENS KEY FIELD IN UR STRUCTURE.*

NOTE:IN YOUR LAYOUT DOUBLE CLICK ON TABLE CONTROL AND AT BOTTOM CHECK THE CHECK BOX AND NAME IT AS WA-S_FLAG.THIS SHOULD BE DONE BEFORE FLOW LOGIC OTHERWISE IT WONT WORK.......