ABAP Forum
cancel
Turn on suggestions
Showing results for
Search instead for
Did you mean:
The next set of progression badges have been announced! Let's Discuss!
Read only

Add screen text field dynamically

jeff_broodwar
Active Participant

4 weeks ago

0 Kudos
1,447

Hi Friends,

I tried to search but can't find an approach to this. Is there a way to add a text field, text label to a screen using a button or an icon from the tool bar (New items icon). Similar to transaction MB1A (2nd screen) where if I click on new items, it will add text fields on the screen (please see screenshot), adding 4th, 5th lines...

MB1A.jpg

Thank you.

Geoff

1 ACCEPTED SOLUTION
Read only

TMNielsen

2 weeks ago

1,176

Hi Sandra

Actually it is MB1A that is obsolete (OSS note 2210569). Step loop is a bit dusty old technique, but I'm almost sure it is not totally obsolete.

I am still using step-loop for RF transactions running via webgui on android scanners. In this scenarios table control and ALV are not useful alternatives.

In general I agree that the functionality to dynamically add a line to a table on screen can also be made with table controls or ALV. The 3 options has each their own look and feel.

@jeff_broodwar if you want to use the same technique as MB1A, then you should search for ABAP step loop. You will find plenty of documentation online. Most of what you find will be around 20 years old, but it should still work.
I found Step-Loops in Module Pool Programming | PDF | Screenshot | Computer Science . This seems to explain it in a good way, but this site requires login.

There is also a little SAP standard documentation:
Step Loop
Creating a step loop in screen painter

Best Regards
Thomas Madsen Nielsen

9 REPLIES 9
Read only

Foxi
Participant

2 weeks ago - last edited 2 weeks ago

0 Kudos
1,262

Hi,

that’s a limitation of classic Dynpro. Screens are statically compiled, so you cannot really add new fields at runtime. What MB1A does is show more rows in a table control, not new fields. If you need truly dynamic behavior, you should look into SAPUI5 or Fiori where UI elements can be created or hidden based on user actions or data.

Cheers,
Sebastian

Read only

jeff_broodwar
Active Participant

2 weeks ago

0 Kudos
1,244

Thank you for the feedback. you mean to say MB1A has a certain number of fields already created and just makes them visible after clicking on New icon?

Read only

Sandra_Rossi
Active Contributor

2 weeks ago

0 Kudos
1,256

What do you want to do exactly?

Read only

jeff_broodwar

2 weeks ago

0 Kudos
1,244

thank you for the joining, as described, similar behavior like MB1A's new fields being generated when New icon is clicked. Thanks.

Read only

Sandra_Rossi

2 weeks ago

1,222

You are repeating what you have said in your question, so your question is still imprecise.

If you mean generating new fields of any type anywhere in the screen, then the answer is no because generating a Dynpro screen is not recommended, especially when it's a standard screen.

For information, MB1A is using the obsolete technology Step Loop.

Instead of Step Loop, use Table Controls or editable ALV Grid. In all cases, you may add new rows as you wish. Adding new columns is possible dynamically, especially with ALV Grid.

Read only

TMNielsen

2 weeks ago

1,177

Hi Sandra

Actually it is MB1A that is obsolete (OSS note 2210569). Step loop is a bit dusty old technique, but I'm almost sure it is not totally obsolete.

I am still using step-loop for RF transactions running via webgui on android scanners. In this scenarios table control and ALV are not useful alternatives.

In general I agree that the functionality to dynamically add a line to a table on screen can also be made with table controls or ALV. The 3 options has each their own look and feel.

@jeff_broodwar if you want to use the same technique as MB1A, then you should search for ABAP step loop. You will find plenty of documentation online. Most of what you find will be around 20 years old, but it should still work.
I found Step-Loops in Module Pool Programming | PDF | Screenshot | Computer Science . This seems to explain it in a good way, but this site requires login.

There is also a little SAP standard documentation:
Step Loop
Creating a step loop in screen painter

Best Regards
Thomas Madsen Nielsen

Read only

jeff_broodwar

2 weeks ago

0 Kudos
1,162

Sorry Sandra, I thought my question is clear, not sure how to describe it further. Furthermore, others were able to suggest or answer it. Anyway, thank you for your interest.

Read only

Sandra_Rossi

2 weeks ago

0 Kudos
1,156

Good to know.

Probably you were simply asking how to add one row. What was missing in my answer is probably a link to the documentation of Step Loop then 😄

Read only

AlexanderOv
Product and Topic Expert
Product and Topic Expert

2 weeks ago - last edited 2 weeks ago

0 Kudos
1,147

Hi Geoff, you can try also the following way:

  • create a dynpro screen with a custom control
  • instantiate custom control object of class CL_GUI_CUSTOM_CONTAINER (for example in PBO)
  • (optionally) create a splitter object (class CL_GUI_SPLITTER_CONTAINER) if you need several containers for your objects
  • create dynamically your screen objects in the corresponding containers. In your case it could be class CL_GUI_INPUT_FIELD. You can find further suitable classes as subclasses of CL_GUI_CONTROL.

Last time I checked this approach, it had several limitations and was not really convenient for my solution, although it could be suitable for some of your use cases.

AltStyle によって変換されたページ (->オリジナル) /