2
votes

I want to show text on input field in the screen, which is value from work area, respectivetly name, age and city, as you can see. When I declare znew_fdkey01 and znew_fdkey02 (which are transparent tables) with using TABLES keyword like this:

TABLES: znew_fdkey01, znew_fdkey02.

it works perfectly. But when I want to obtain the same effect without using this keyword, and when I declare variables like this:

DATA: znew_fdkey01 TYPE znew_fdkey01,
      znew_fdkey02 TYPE znew_fdkey02.

it does not show me text in the input field.

Why?

NB: here is the code to initialize the screen fields (the same in both cases):

LOOP AT SCREEN INTO screen_wa.

  IF screen_wa-name = 'ZNEW_FDKEY01-NAME'.
    znew_fdkey01-name = lr_znewfdkey3-name.
  ENDIF.

  IF screen_wa-name = 'ZNEW_FDKEY01-AGE'.
    znew_fdkey01-age = lr_znewfdkey3-age.
  ENDIF.

  IF screen_wa-name = 'ZNEW_FDKEY02-CITY'.
    znew_fdkey02-city = lr_znewfdkey3-city.
  ENDIF.

  MODIFY SCREEN FROM screen_wa.

ENDLOOP.
2
The question was not explicitly asked, I added "Why?" (after your last sentence "it does not show me text in the input field.")Sandra Rossi
NB: I don't answer your question, but your latest code LOOP AT SCREEN does not help for answering the question. Moreover this statement is useful only to change the attributes of screen fields at run time (like hiding, protecting against input, etc.) so the loop can be omitted, just keep these 3 lines: znew_fdkey01-name = lr_znewfdkey3-name. znew_fdkey01-age = lr_znewfdkey3-age. znew_fdkey02-city = lr_znewfdkey3-city.Sandra Rossi
how your input fields are declared?Suncatcher
In a screen painterusername1995.

2 Answers

2
votes

This is correct, TABLES defines work areas and at the same time it is necessary to ensure the automatic communication between the screen (dynpro) and the ABAP program, as documented in the ABAP Help:

Table work areas declared using TABLES are interface work areas...

The statement TABLES is required for exchanging data between dynpro fields and the ABAP program, if the fields were defined in a dynpro in the program by being taken from ABAP Dictionary, . In the dynpro event PBO, the content of the table work area is passed to identically named dynpro fields. In PAI, the system takes the data from identically named dynpro fields.

(Otherwise don't use TABLES to declare work areas, that is obsolete)

0
votes

You must use TABLES only if you define your screen input/output field as a "DDIC" field (Data/ABAP Dictionary). This is a checkbox defined in the Screen Painter for each screen field.

There are two possibilities:

  • Either you name your screen I/O field like according to an existing DDIC structure field (as you did, ZNEW_FDKEY01-NAME) and you define it as a "DDIC" field (it's a field attribute in the Screen Painter) and you must use TABLES to transfer values.
  • Or you don't define your screen input field as a "DDIC" field, and you define the field name as a global variable in your program, using TABLES is completely optional. But in that case, you lose some features in the screen that are unique to the DDIC, like the reuse of DDIC labels (any change impacts all screens), the Value Help/F4 like the search help implying multiple fields (but you can still code it in ABAP from scratch), etc.

Example:

  • Create this program:
    TABLES spfli. " Mandatory as screen field SPFLI-CARRID is connected to the "DDIC"
    DATA scarr TYPE scarr. " or TABLES scarr if you wish
    
    spfli-carrid = 'LH'.
    scarr-carrname = 'Name of company'.
    
    CALL SCREEN 100.
    
    MODULE screen_0100_pai INPUT.
      LEAVE TO SCREEN 0.
    ENDMODULE.
    
  • Create the dynpro 0100 with these fields (pay attention to "Dict.field")
    Name             Type Line Col. Def Vis Format Inp Out  Dict.field
    SPFLI-CARRID     I/O  1    18   3   3   CHAR   X   X    X
    SCARR-CARRNAME   I/O  2    18   20  20  CHAR   X   X   
    
  • and this flow logic:
    PROCESS BEFORE OUTPUT.
    PROCESS AFTER INPUT.
      MODULE SCREEN_0100_PAI.
    
  • Activate and run the program.
  • Result as expected:
    enter image description here