on 01-18-2013 11:40 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Experts,Thanks for all your suggesstions,
i did it,I made a node in the context having the attributes of the table and finally updated in ztable.
method onactionsubmit.
DATA:
NODE_ZR TYPE REF TO IF_WD_CONTEXT_NODE,
EL_ZR TYPE REF TO IF_WD_CONTEXT_ELEMENT,
LS_ZR TYPE IF_REGT=>ELEMENT_REG,
WA_ZR TYPE ZRESUME.
DATA:
VA_MAIL LIKE LS_ZR-ZMAIL,
VA_FNAME LIKE LS_ZR-FNAME,
VA_LNAME LIKE LS_ZR-LNAME,
VA_GENDER LIKE LS_ZR-GENDER,
VA_DOB LIKE LS_ZR-DOB,
VA_COUNTRY LIKE LS_ZR-COUNTRY,
VA_NATIONALITY LIKE LS_ZR-NATIONALITY,
VA_ADD1 LIKE LS_ZR-ADD1,
VA_DIST LIKE LS_ZR-DIST,
VA_CODE LIKE LS_ZR-CODE,
VA_COUNTRY1 LIKE LS_ZR-COUNTRY1,
VA_ZPWD LIKE LS_ZR-ZPWD,
VA_ZUSD LIKE LS_ZR-ZUSD.
NODE_ZR = WD_CONTEXT->GET_CHILD_NODE( NAME = 'REG' ).
EL_ZR = NODE_ZR->GET_ELEMENT( ).
EL_ZR->GET_ATTRIBUTE(
EXPORTING
NAME = 'ZMAIL'
IMPORTING
VALUE = VA_MAIL ).
EL_ZR->GET_ATTRIBUTE(
EXPORTING
NAME = 'FNAME'
IMPORTING
VALUE = VA_FNAME ).
EL_ZR->GET_ATTRIBUTE(
EXPORTING
NAME = 'LNAME'
IMPORTING
VALUE = VA_LNAME ).
EL_ZR->GET_ATTRIBUTE(
EXPORTING
NAME = 'GENDER'
IMPORTING
VALUE = VA_GENDER ).
EL_ZR->GET_ATTRIBUTE(
EXPORTING
NAME = 'DOB'
IMPORTING
VALUE = VA_DOB ).
EL_ZR->GET_ATTRIBUTE(
EXPORTING
NAME = 'COUNTRY'
IMPORTING
VALUE = VA_COUNTRY ).
EL_ZR->GET_ATTRIBUTE(
EXPORTING
NAME = 'NATIONALITY'
IMPORTING
VALUE = VA_NATIONALITY ).
EL_ZR->GET_ATTRIBUTE(
EXPORTING
NAME = 'ADD1'
IMPORTING
VALUE = VA_ADD1 ).
EL_ZR->GET_ATTRIBUTE(
EXPORTING
NAME = 'DIST'
IMPORTING
VALUE = VA_DIST ).
EL_ZR->GET_ATTRIBUTE(
EXPORTING
NAME = 'CODE'
IMPORTING
VALUE = VA_CODE ).
EL_ZR->GET_ATTRIBUTE(
EXPORTING
NAME = 'COUNTRY1'
IMPORTING
VALUE = VA_COUNTRY1 ).
EL_ZR->GET_ATTRIBUTE(
EXPORTING
NAME = 'ZPWD'
IMPORTING
VALUE = VA_ZPWD ).
EL_ZR->GET_ATTRIBUTE(
EXPORTING
NAME = 'ZUSD'
IMPORTING
VALUE = VA_ZUSD ).
WA_ZR-ZMAIL = VA_MAIL.
WA_ZR-FNAME = VA_FNAME.
WA_ZR-LNAME = VA_LNAME.
WA_ZR-GENDER = VA_GENDER.
WA_ZR-DOB = VA_DOB.
WA_ZR-COUNTRY = VA_COUNTRY.
WA_ZR-NATIONALITY = VA_NATIONALITY.
WA_ZR-ADD1 = VA_ADD1.
WA_ZR-DIST = VA_DIST.
WA_ZR-CODE = VA_CODE.
WA_ZR-COUNTRY1 = VA_COUNTRY1.
WA_ZR-ZPWD = VA_ZPWD.
WA_ZR-ZUSD = VA_ZUSD.
INSERT INTO ZRESUME VALUES WA_ZR.
endmethod.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ritika,
You can directly use insert command to insert records into db table in webdynpro abap. But for better performance and to follow MVC pattern, create an assistance class and do all the work related to database(insert\modify\delete) here.
Regards,
Mahidhar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.