cancel
Showing results for 
Search instead for 
Did you mean: 

Webdynpro code

Former Member
0 Kudos

Dear Expertise

I have created a login page  in webdynpro.

here's the screenshots as-

Main

View

after clicking new user from main window, i should go to view window and fill the details , then that data should be save in Z-table.

Can anyone help me with this?

Regards

varun

Accepted Solutions (1)

Accepted Solutions (1)

former_member183072
Active Participant
0 Kudos

Hello,

If I understand it correctly, you need the steps how to do that:

For the button 'New user' create a action. In this action you need to 'fire to a plug'(call the view). In this view you got the input fields that are connected to a node in the context.

After the user fill up the data in the input fields, for the button 'Submit' create a new action in which you read the context node to get the data from the view , and this data you will update your database table.

Have fun,

Hancila

Former Member
0 Kudos

Hello

Almost all steps i have done .

Problem lies when i am reading my input fields from in submit method,

How to save that particular value in to Z-table.

Regards

varun

aarif_baig
Active Participant
0 Kudos

Hi Varun,

               As i mentioned in my last reply to your other post.

just see an example

you have 3 fields A, B, C and you have ztable which has all these 3 fields

DATA : wa TYPE ztable.

wa-a = x.

wa-b = y.

wa-c = z.

update ztable from wa.

cheers

Former Member
0 Kudos

Hi,

Read the context nodes with the help of code wizard.And save/update the required values into your Z-Table .

Thanks

KH

harsha_jalakam
Active Contributor
0 Kudos

Hi Varun,

You can use below sql statement to insert the records, as per your requirement. 

INSERT INTO TABLE_NAME VALUES LS_STRUCTURE.


where TABLE_NAME is the name of the table & LS_STRUCTURE is the structure values obtained by reading the context.


Thank You,

Harsha

former_member183072
Active Participant
0 Kudos

Data wa type z-table.

wa-userid = lv_userid.

wa-paswd = lv_passwd.

wa-name - lv_name.

update z-table from wa.

commit work.

Former Member
0 Kudos

Hello

Can you modify my code as i have pasted in above reply.

I will be thankful to you.

Regards

varun

aarif_baig
Active Participant
0 Kudos

DATA lo_nd_node1 TYPE REF TO if_wd_context_node.

     DATA lo_el_node1 TYPE REF TO if_wd_context_element.

     DATA ls_node1 TYPE wd_this->Element_node1.

     DATA lv_user_id TYPE wd_this->Element_node1-user_id.

*   navigate from <CONTEXT> to <NODE1> via lead selection

     lo_nd_node1 = wd_context->get_child_node( name = wd_this->wdctx_node1 ).

*   @TODO handle non existant child

*   IF lo_nd_node1 IS INITIAL.

*   ENDIF.

*   get element via lead selection

     lo_el_node1 = lo_nd_node1->get_element( ).

*   alternative access  via index

*   lo_el_node1 = lo_nd_node1->get_element( index = 1 ).

*   @TODO handle not set lead selection

     IF lo_el_node1 IS INITIAL.

     ENDIF.

*   get single attribute

     lo_el_node1->get_attribute(

       EXPORTING

         name `USER_ID`

       IMPORTING

         value = lv_user_id ).

       DATA lo_nd_login TYPE REF TO if_wd_context_node.

       DATA lo_el_login TYPE REF TO if_wd_context_element.

       DATA ls_login TYPE wd_this->Element_login.

       DATA lv_name TYPE wd_this->Element_login-name.

*     navigate from <CONTEXT> to <LOGIN> via lead selection

       lo_nd_login = wd_context->get_child_node( name = wd_this->wdctx_login).

*     @TODO handle non existant child

*     IF lo_nd_login IS INITIAL.

*     ENDIF.

*     get element via lead selection

       lo_el_login = lo_nd_login->get_element( ).

*     alternative access  via index

*     lo_el_login = lo_nd_login->get_element( index = 1 ).

*     @TODO handle not set lead selection

       IF lo_el_login IS INITIAL.

       ENDIF.

*     get single attribute

       lo_el_login->get_attribute(

         EXPORTING

           name `NAME`

         IMPORTING

           value = lv_name ).

       DATA lo_nd_passwd TYPE REF TO if_wd_context_node.

       DATA lo_el_passwd TYPE REF TO if_wd_context_element.

       DATA ls_passwd TYPE wd_this->Element_passwd.

       DATA lv_passwd TYPE wd_this->Element_passwd-passwd.

*     navigate from <CONTEXT> to <PASSWD> via lead selection

       lo_nd_passwd = wd_context->get_child_node( name = wd_this->wdctx_passwd ).

*     @TODO handle non existant child

*     IF lo_nd_passwd IS INITIAL.

*     ENDIF.

*     get element via lead selection

       lo_el_passwd = lo_nd_passwd->get_element( ).

*     alternative access  via index

*     lo_el_passwd = lo_nd_passwd->get_element( index = 1 ).

*     @TODO handle not set lead selection

       IF lo_el_passwd IS INITIAL.

       ENDIF.

*     get single attribute

       lo_el_passwd->get_attribute(

         EXPORTING

           name `PASSWD`

         IMPORTING

           value = lv_passwd ).


Data wa type z-table.

wa-userid = lv_userid.

wa-paswd = lv_passwd.

wa-name - lv_name.

update z-table from wa.

commit work.

check the modified code just change the name of ztable to the table u want to update.

cheers

Former Member
0 Kudos

Hi

I  have used this code as you have told.

Its throwing error as-

Regards

varun

aarif_baig
Active Participant
0 Kudos

Hi Varun,

               Double clieck on this error and go to that statement wd_this->wdctx_login )  put a space after login

ramakrishnappa
Active Contributor
0 Kudos

Hi Varun,

This error is because, you have not given space between "wd_this->wdctx_login" & ")". Try to give space and check.

Regards,

Rama

Former Member
0 Kudos

Hi

Its showing error

Type "z" is unknown.

Regards

varun

Former Member
0 Kudos

Can you provide the snapshot of the error?

Former Member
0 Kudos

Hello

i have created a node which has 3 attributes.

i have use code wizard and my code is as-

method ONACTIONSAVE .
        DATA lo_nd_node1 TYPE REF TO if_wd_context_node.

        DATA lo_el_node1 TYPE REF TO if_wd_context_element.
        DATA ls_node1 TYPE wd_this->Element_node1.

*      navigate from <CONTEXT> to <NODE1> via lead selection
        lo_nd_node1 = wd_context->get_child_node( name = wd_this->wdctx_node1 ).

*      @TODO handle non existant child
*      IF lo_nd_node1 IS INITIAL.
*      ENDIF.

*      get element via lead selection
        lo_el_node1 = lo_nd_node1->get_element( ).
*      alternative access  via index
*      lo_el_node1 = lo_nd_node1->get_element( index = 1 ).
*      @TODO handle not set lead selection
        IF lo_el_node1 IS INITIAL.
        ENDIF.

*      get all declared attributes
         lo_el_node1->get_static_attributes(
          IMPORTING
            static_attributes = ls_node1 ).



Data wa type z-table.

wa-userid = lv_userid.

wa-paswd = lv_passwd.

wa-name - lv_name.

update z-table from wa.

commit work.



        

ENDMETHOD.


Can you check what should be next to update or save the values in Z-table


Regards

varun

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi

What is a neccessary set when user is valid?

Thank you

ramakrishnappa
Active Contributor
0 Kudos

Hi Varun,

I don't see is it a good idea to have to store user credentials in a z-table, which can be accessed by anyone, and can login , if you need to store passwords, are you considering the encryption?

What are you trying to achieve from this?

...................

Regarding your approach of development

...................

Why are you creating separate context nodes for each fields viz, user id, password?

  •      Instead, create one node - REG_USER with attributes NAME, USER_ID, PASSWORD, C_PASSWORD etc.
  • Read the static attributes of node at once and use it for further processing

              

               data lo_node type ref to if_wd_context_node.

               data ls_user_reg type wd_this->element_REG_USER

          lo_node->GET_STATIC_ATTRIBUTES( receiving static_attributes = ls_user_reg )

  • Now create a temp work area of type z-table

               data ls_zdata type z_user_data.

               move-corresponding ls_user_reg to ls_zdata.

              

               modify Z_USER_DATA from ls_zdata.

Regards,

Rama

Former Member
0 Kudos

Hello

i have created a node which has 3 attributes.

i have use code wizard and my code is as-

method ONACTIONSAVE .
        DATA lo_nd_node1 TYPE REF TO if_wd_context_node.

        DATA lo_el_node1 TYPE REF TO if_wd_context_element.
        DATA ls_node1 TYPE wd_this->Element_node1.

*      navigate from <CONTEXT> to <NODE1> via lead selection
        lo_nd_node1 = wd_context->get_child_node( name = wd_this->wdctx_node1 ).

*      @TODO handle non existant child
*      IF lo_nd_node1 IS INITIAL.
*      ENDIF.

*      get element via lead selection
        lo_el_node1 = lo_nd_node1->get_element( ).
*      alternative access  via index
*      lo_el_node1 = lo_nd_node1->get_element( index = 1 ).
*      @TODO handle not set lead selection
        IF lo_el_node1 IS INITIAL.
        ENDIF.

*      get all declared attributes
         lo_el_node1->get_static_attributes(
          IMPORTING
            static_attributes = ls_node1 ).



Data wa type z-table.

wa-userid = lv_userid.

wa-paswd = lv_passwd.

wa-name - lv_name.

update z-table from wa.

commit work.



        

ENDMETHOD.


Can you check what should be next to update or save the values in Z-table


Regards

varun

ramakrishnappa
Active Contributor
0 Kudos

Hi Varun,

Just modify the code as below

Data wa type z-table.

move-corresponding ls_node1 to wa.

modify z-table from wa.

commit work.

Regards,

Rama

aarif_baig
Active Participant
0 Kudos

Hi varun,

                 Ztable is the name oftable you want to update, replace ztable with the table you want to update

Former Member
0 Kudos

Hi

error

last party of code as-

Data wa type zentry.


wa-userid = lv_userid.

wa-paswd = lv_passwd.

wa-name = lv_name.


MOVE-CORRESPONDING ls_node1 to wa.
modify zentry from wa.

*update zentry from wa.

commit work.


ZENTRY is my table name.


Regards

varun

Former Member
0 Kudos

Hi

error

last party of code as-

Data wa type zentry.


wa-userid = lv_userid.

wa-paswd = lv_passwd.

wa-name = lv_name.


MOVE-CORRESPONDING ls_node1 to wa.
modify zentry from wa.

*update zentry from wa.

commit work.


ZENTRY is my table name.


Regards

varun

aarif_baig
Active Participant
0 Kudos

Hi varun it is

Wa-userid = LV_USER_ID

Former Member
0 Kudos

Hi

I have done that but coming with same error.

do i have to declare all fields separately.

Regards

varun

aarif_baig
Active Participant
0 Kudos

I don't see any point if you are using LV_USER_ID and still getti g an issue pls paste the code

Former Member
0 Kudos

Here's the code as-

method ONACTIONSAVE .
        DATA lo_nd_node1 TYPE REF TO if_wd_context_node.

        DATA lo_el_node1 TYPE REF TO if_wd_context_element.
        DATA ls_node1 TYPE wd_this->Element_node1.

*      navigate from <CONTEXT> to <NODE1> via lead selection
        lo_nd_node1 = wd_context->get_child_node( name = wd_this->wdctx_node1 ).

*      @TODO handle non existant child
*      IF lo_nd_node1 IS INITIAL.
*      ENDIF.

*      get element via lead selection
        lo_el_node1 = lo_nd_node1->get_element( ).
*      alternative access  via index
*      lo_el_node1 = lo_nd_node1->get_element( index = 1 ).
*      @TODO handle not set lead selection
        IF lo_el_node1 IS INITIAL.
        ENDIF.

*      get all declared attributes
         lo_el_node1->get_static_attributes(
          IMPORTING
            static_attributes = ls_node1 ).


Data wa type zentry.


wa-userid = lv_user_id.

wa-password = lv_password.

wa-name = lv_name.


MOVE-CORRESPONDING ls_node1 to wa.
modify zentry from wa.

*update zentry from wa.

commit work.





ENDMETHOD.


Actually i have changed the design as well.

Created one node and in that created 3 attributes and finally read the values from code wizard.


Regards

varun

aarif_baig
Active Participant
0 Kudos

Ok so if lsnode1 has the same field name as your ztable then just use move-corresponding remove

Wa-userid and all wa statement

Former Member
0 Kudos

Hi

Yes its working with no error .

Final , How can i check whether data is being updated in z-table.

Regards

varun

aarif_baig
Active Participant
0 Kudos

Go and check zentry table in se16 and c that data u put on the screen is there or not once u have saved the data and then u can close this thread

Former Member
0 Kudos

Hi

Issues are still there .

Data is not being updated in Z-table

and whenever i enter password, it is again display in re-password  after clicking enter.

Regards

varun

aarif_baig
Active Participant
0 Kudos

Put a breakpoint and check what is going wrong check if wa has value assigned to it

Former Member
0 Kudos

Hi

after filling values

got error as-

ERROR: Unable to interpret ACP Rane as a number. (termination: RABAX_STATE)

Regards

varun

aarif_baig
Active Participant
0 Kudos

Hi varun acp rane is a name  and you should assign this value to character data type field check the field of the table in which yiu are passing this value has character data type defined

Former Member
0 Kudos

Hi,

I think you've binded re-enter password field context attribute value with password field context value attribute. That's why it is giving you such error.

Thanks

KH

Former Member
0 Kudos

Hi

I have use same fields in both .

Help.

Regards

varun

Former Member
0 Kudos

Hi

I have use same fields in both .

Help.

Regards

varun

aarif_baig
Active Participant
0 Kudos

There is a problem inur table passsword has got 3 s and in dynpro it is password how  have created a node have u inherited zentry pls check

Former Member
0 Kudos

Hi

i have check that

Now , screen shot of table and webdynpro is

I have use Userid as NumC

Now, when i debug

Its throwing error as

Overflow when converting 108062 from

Help.

Regards

varun

aarif_baig
Active Participant
0 Kudos

When u r creating a node just inherit zentry using dictionary option that will make it easy

aarif_baig
Active Participant
0 Kudos

Update the node first with zentry table and then check I think userid what you have defined indynpro has different data type

Former Member
0 Kudos

Hi

I have use data type as STRING for my dynpro fields .

Help.

Regards

varun

aarif_baig
Active Participant
0 Kudos

Varun y dont u do a simple thing just update the node and make it same as zentry cright click on node and change then select zentry and add all fields from there it will make it very easy then

Former Member
0 Kudos

Hi

screenshot of debugging as-

Regards

varun

aarif_baig
Active Participant
0 Kudos

Varub userid here shows it is int2, but the userid in table it is numeric  y so?

Former Member
0 Kudos

Hi

I have changed that

Now , when i debug , no error and

WA has values which i enter in screen . But still not updated in Z-table.

help.

Regards

varun

aarif_baig
Active Participant
0 Kudos

Use insert instead of modify and give it a try

Former Member
0 Kudos

Hi

I am getting  entries now using MODIFY.

Now further i have to see that whenever I fill login and password it should open another page or window displaying simple

Login name or watever we have filled.

and if login and password doesn/t match , it should  not able to login.

Help.

Regards

varun

aarif_baig
Active Participant
0 Kudos

Varun please close this thread and open a new one with new query

Former Member
0 Kudos

HI

actually its a continuation of  task .

Regards

varun

Former Member
0 Kudos

Hi

Now further i have to see that whenever I fill login and password it should open another page or window displaying simple

Login name or watever we have filled.

and if login and password doesn/t match , it should  not able to login.

Help.

Regards

varun

aarif_baig
Active Participant
0 Kudos

Hi Varun,

               I think i already replied to you in previous thread which due to some reasons is not there anymore

what did you do with previous thread?

Former Member
0 Kudos

Hi

Yes you told me to do the code . That's for a single field.

I have  more fields. Do i have to read one by one all.

Regards

varun

aarif_baig
Active Participant
0 Kudos

Yes you have to if you have defined them separately

Former Member
0 Kudos

Hi

Ok , its done .i have read all the values separately .

but final query is How to update that values in Z-table?

Regards

varun

former_member183072
Active Participant
0 Kudos

You got the values in a local structure/table. Maybe this local structure/table is not the same type like your z-table. You need to move all values to a structure/table type z-table, and after that update z-table from local structure/table.

Hope you understand,

Hancila

Former Member
0 Kudos

Hello

Yeah i understand

I am pasting a screenshot of my code as-

method ONACTIONSAVE .
     DATA lo_nd_node1 TYPE REF TO if_wd_context_node.

     DATA lo_el_node1 TYPE REF TO if_wd_context_element.
     DATA ls_node1 TYPE wd_this->Element_node1.
     DATA lv_user_id TYPE wd_this->Element_node1-user_id.

*   navigate from <CONTEXT> to <NODE1> via lead selection
     lo_nd_node1 = wd_context->get_child_node( name = wd_this->wdctx_node1 ).

*   @TODO handle non existant child
*   IF lo_nd_node1 IS INITIAL.
*   ENDIF.

*   get element via lead selection
     lo_el_node1 = lo_nd_node1->get_element( ).
*   alternative access  via index
*   lo_el_node1 = lo_nd_node1->get_element( index = 1 ).
*   @TODO handle not set lead selection
     IF lo_el_node1 IS INITIAL.
     ENDIF.

*   get single attribute
     lo_el_node1->get_attribute(
       EXPORTING
         name `USER_ID`
       IMPORTING
         value = lv_user_id ).

       DATA lo_nd_login TYPE REF TO if_wd_context_node.

       DATA lo_el_login TYPE REF TO if_wd_context_element.
       DATA ls_login TYPE wd_this->Element_login.
       DATA lv_name TYPE wd_this->Element_login-name.

*     navigate from <CONTEXT> to <LOGIN> via lead selection
       lo_nd_login = wd_context->get_child_node( name = wd_this->wdctx_login ).

*     @TODO handle non existant child
*     IF lo_nd_login IS INITIAL.
*     ENDIF.

*     get element via lead selection
       lo_el_login = lo_nd_login->get_element( ).
*     alternative access  via index
*     lo_el_login = lo_nd_login->get_element( index = 1 ).
*     @TODO handle not set lead selection
       IF lo_el_login IS INITIAL.
       ENDIF.

*     get single attribute
       lo_el_login->get_attribute(
         EXPORTING
           name `NAME`
         IMPORTING
           value = lv_name ).

       DATA lo_nd_passwd TYPE REF TO if_wd_context_node.

       DATA lo_el_passwd TYPE REF TO if_wd_context_element.
       DATA ls_passwd TYPE wd_this->Element_passwd.
       DATA lv_passwd TYPE wd_this->Element_passwd-passwd.

*     navigate from <CONTEXT> to <PASSWD> via lead selection
       lo_nd_passwd = wd_context->get_child_node( name = wd_this->wdctx_passwd ).

*     @TODO handle non existant child
*     IF lo_nd_passwd IS INITIAL.
*     ENDIF.

*     get element via lead selection
       lo_el_passwd = lo_nd_passwd->get_element( ).
*     alternative access  via index
*     lo_el_passwd = lo_nd_passwd->get_element( index = 1 ).
*     @TODO handle not set lead selection
       IF lo_el_passwd IS INITIAL.
       ENDIF.

*     get single attribute
       lo_el_passwd->get_attribute(
         EXPORTING
           name `PASSWD`
         IMPORTING
           value = lv_passwd ).



ENDMETHOD.

Can you help  by looking the code

Regards

varun

aarif_baig
Active Participant
0 Kudos

does your ztable have all these 3 fields if yes then

just collect these values in one work area which should be like your ztable

wa-userid = lv_userid.

wa-paswd = lv_passwd.

wa-name - lv_name.

update ztable from wa.

commit work.

what is the problem you need to add the above code.

Former Member
0 Kudos

Hi,

Declare one workarea of type <your custom table name>.

now assign the require field values into your workarea.

for ex : lw_workarea-newuser = lv_name .

            lw_workarea-passwd  = lv_passwd.

           

            now update your ztable with above workarea containing field values.

Thanks

KH

         

Former Member
0 Kudos

Hi

I have that fields

Problem is where to add this particular code in my Code which i have used from code wizard.

Can you check my code which i have pasted in above reply.

Regards

varun

Former Member
0 Kudos

hi,

create on action even for submit button.u can check subit button properties and give the action name(event name).inside submit action method write the code(use the code wizard to read the values from the input field) and update the ztable.

Best regards,

Noufal P

Former Member
0 Kudos

Hi

After clicking on submit button, do i have to read all the inputs together or one by one .

and how it will be saved in Z-table.

Regards

varun

Former Member
0 Kudos

it based on your requirement..you can read node as structure..or each attribute of a node and assing it to work area field one by one and finally update your ztable

best regards,

Noufal p

Former Member
0 Kudos

Hi Varun,

Are these two windows or views ?

If they are views, what you can do is create the nodes accordingly in component controller and read them in both the view.

For navigating between views you can make use of inbound and outbound plugs.


Regards,

Aakash

Former Member
0 Kudos

Hi

Both are views .

I have created the nodes and attributes as you can see from the above posted screenshots.

Problem is with how to read the values and set them or save them in particular Z-table.

Regards

varun