Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

HOW TO SAVE USER INPUT FORM INTO DB USING WEBDYNPRO ABAP

Hello All,

I am trying to make a registration form in abap-web dynpro which will take all the inputs from user and will save in a Z table.

Please guide me if possible.

I am getting the idea that we have to take all the inputs and then insert it.

Regards

Tags:
Former Member
Former Member replied

Greetings Ritika

The way I did it is that firstly I went into the context of the view. I then defined the Attributes such as first name, last name, address and so on. Then I went into the layout and created the input fields and the button. When the basic layout of the form was done I created an action method.I used the following code.

METHOD.

DATA LO_EL_CONTEXT  TYPE REF TO IF_WD_CONTEXT_ELEMENT.

DATA LS_CONTEXT        TYPE WD_THIS->ELEMENT_CONTEXT.

DATA LV_FIRST_NAME  TYPE WD_THIS->ELEMENT_CONTEXT-FIRST_NAME.

DATA LV_LAST_NAME   TYPE WD_THIS->ELEMENT_CONTEXT- LAST_NAME.

DATA LV_ADDRESS       TYPE WD_THIS->ELEMENT_CONTEXT-ADDRESS.

DATA WA_ENTRY          TYPE ZENTRY.

*get element via lead selection

lo_el_context = wd_context->get_element ( ).

* @TODO handle not set lead selection

IF lo_el_context IS INITIAL.

ENDIF.

* get single attribute

lo_el_context->get_attribute (

EXPORTING

  NAME = ' FIRST_NAME'

IMPORTING

VALUE = LV_FIRST_NAME ).

*get element via lead selection

lo_el_context = wd_context->get_element ( ).

* @TODO handle not set lead selection

IF lo_el_context IS INITIAL.

ENDIF.

* get single attribute

lo_el_context->get_attribute (

EXPORTING

  NAME = ' LAST_NAME'

IMPORTING

VALUE = LV_LAST_NAME ).

*get element via lead selection

lo_el_context = wd_context->get_element ( ).

* @TODO handle not set lead selection

IF lo_el_context IS INITIAL.

ENDIF.

* get single attribute

lo_el_context->get_attribute (

EXPORTING

  NAME = ' ADDRESS'

IMPORTING

VALUE = LV_ADDRESS ).

WA_ENTRY-FIRST_NAME = LV_FIRST_NAME.

WA_ENTRY-LAST_NAME = LV_LAST_NAME.

WA_ENTRY-ADDRESS = LV_ADDRESS.

INSERT INTO ZENTRY VALUES INTO WA_ENTRY.

ENDMETHOD.

Thats the pattern I used for my entry form and it works well for me. The data is entered in the form and then saved in the database table.

I hope this helps.Greetings.

Črt

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question