Skip to Content

Dynamic Setting of Field Attributes in Table Controls

If you look at most standard SAP transactions that include a table control, you will see that entire columns are either enterable or display only. It is rare for a table control to change the attributes of a single field dynamically, but if you look at transaction SE11 for a “Z” table in change mode and click on the “Currency/Quantity Fields” tab, you’ll see that all of the fields of type “CURR” (currency) have two fields enabled – the reference table and the reference field. All of the other columns and rows are disabled.

If you find yourself being asked to do something similar, the following program should help to guide you along.

Some Things to Note

  • The program is not meant as a tutorial on dialogue programming. It assumes that you are already familiar with those concepts (including using table controls). If you are not, you should get some experience with screen programming before trying this.
  • The program is dirty. I have not taken a great deal of effort to add any extras or do any checking that would normally be done. This is another reason not to use this as a model dialogue program.
  • The program consists of one executable program with a screen and a GUI status.

Getting Started

  • Create a local program with type “1” (executable).
  • Copy the code below into the program

  • Double click on ‘9999′ in the line:    CALL SCREEN 9999.
  • This will take you the screen painter where you can create your screen.
  • I included a number of fields from the data dictionary object BSIS. You don’t need to use all of the ones that I did, but it should match your internal table and you will need at least BSIS-BUZEI, BSIS-DMBTR and BSIS-SHKZG. They will need to be in a table control called MY_CTL. The screen type is “normal” and the next screen is just 9999.
  • When you copy the fields into the table control, take the default attributes.
  • Create two other check-box fields outside of the table control. One is disp_credits and the other is disp_debits. Here, also take the default attributes with one exception – if you give each of these fields a separate function code (Fct/Code) in the screen painter, you will be able to see the changes immediately rather than having to press the “Enter” key.
  • Copy the following code into the flow logic for the screen.

  • Back in the program, double click on ‘STD’ in the line:  SET PF-STATUS ‘STD’.
  • This will take you to the user interface maintenance screen. You will need to create a simple GUI status here that allows you to get out of the screen. You can simply enter ‘CAN’ above the red “X” in the standard toolbar in the “Function keys”. Then click on the red “X” to bring up the function attributes. The Function type should be ‘E’ (exit command). The screen will then recognize the “cancel” button correctly.
  • Save and activate everything.

Seeing what’s going on

When you first execute the program, it will bring in some data from BSIS and populate the table control. Assuming that you have been able to retrieve line items some with item number 1 and others with other item numbers, some item number fields will be display only; all of the others will be enterable.

Then, if you check one of the check-boxes, all of the line items will be enterable, but depending on which check-box you tick, some of the amounts will now be display only.

A Final Caveat

  • This program and screen was developed in 4.7 and tested in both 4.7 and ECC 6.0. I developed a similar program in 4.5B. So this should work in most systems.
1 Comment
You must be Logged on to comment or reply to a post.