cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a field by validating other field in a table in webdynpro

Former Member
0 Kudos

Hi,

My requirement is to feed a ztable through a webdynpro component

with the below code am able to get 1st record only

i dont know how to loop in this scenario

am new to webdynpro

help meee

method ONACTIONONSAVE .

   DATA LO_ND_ND_FORM TYPE REF TO IF_WD_CONTEXT_NODE.

   DATA LO_EL_ND_FORM TYPE REF TO IF_WD_CONTEXT_ELEMENT.

   DATA LS_ND_FORM TYPE WD_THIS->ELEMENT_ND_FORM.

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

   LO_ND_ND_FORM = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_ND_FORM ).

* get element via lead selection

   LO_EL_ND_FORM = LO_ND_ND_FORM->GET_ELEMENT( ).

* get all declared attributes

   LO_EL_ND_FORM->GET_STATIC_ATTRIBUTES(

     IMPORTING

       STATIC_ATTRIBUTES = LS_ND_FORM ).

   INSERT ZSILO_CREATE from LS_ND_FORM.

*****************************************************

   DATA LO_ND_ND_TABLE TYPE REF TO IF_WD_CONTEXT_NODE.

   DATA LT_ND_TABLE TYPE WD_THIS->ELEMENTS_ND_TABLE.

   DATA Ls_ND_TABLE TYPE WD_THIS->ELEMENTs_ND_TABLE.

   data wa TYPE  ZSILO_CREAT.

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

   LO_ND_ND_TABLE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_ND_TABLE ).

************

*DATA LO_ND_ND_TABLE TYPE REF TO IF_WD_CONTEXT_NODE.

*    DATA LT_ND_TABLE TYPE WD_THIS->ELEMENTS_ND_TABLE.

*    DATA LS_ND_TABLE TYPE WD_THIS->ELEMENT_ND_TABLE.

     DATA LO_EL_ND_TABLE TYPE REF TO IF_WD_CONTEXT_ELEMENT.

     DATA LV_werks TYPE WD_THIS->ELEMENT_ND_TABLE-werks.

     DATA LV_DIP_HI TYPE WD_THIS->ELEMENT_ND_TABLE-DIP_HI.

     DATA LV_VOL_DIP TYPE WD_THIS->ELEMENT_ND_TABLE-VOL_DIP.

     DATA LV_PRESSURE TYPE WD_THIS->ELEMENT_ND_TABLE-PRESSURE.

     DATA LV_PRESSURE_VOL TYPE WD_THIS->ELEMENT_ND_TABLE-PRESSURE_VOL.

     DATA D_VOL TYPE ZSILO_CREAT-VOL_DIP.

     DATA P_VOL TYPE ZSILO_CREAT-PRESSURE_VOL.

     LO_ND_ND_TABLE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_ND_TABLE ).

     LO_EL_ND_TABLE = LO_ND_ND_TABLE->GET_ELEMENT( ).

*   get single attribute

     LO_EL_ND_TABLE->GET_ATTRIBUTE(

       EXPORTING

         NAME `DIP_HI`

       IMPORTING

         VALUE = LV_DIP_HI ).

     LO_EL_ND_TABLE->GET_ATTRIBUTE(

       EXPORTING

         NAME `PRESSURE`

       IMPORTING

         VALUE = LV_PRESSURE ).

   

*    if lt_nd_table is not INITIAL.

     if lv_dip_hi is not INITIAL.

       CALL FUNCTION 'ZSILO_FM2'

         EXPORTING

           IM_DIP_HI        = lv_dip_hi

        IMPORTING

          EX_VOL_DIP       = d_vol

        EXCEPTIONS

          EXP1             = 1

*         OTHERS           = 2

                 .

lv_vol_dip = D_VOL.

        LO_EL_ND_TABLE->SET_ATTRIBUTE(

          NAME `VOL_DIP`

          VALUE = LV_VOL_DIP ).

        ENDIF.

     IF LV_PRESSURE is not INITIAL.

       CALL FUNCTION 'ZSILO_FM1'

     EXPORTING

       IM_PRESSURE           = lv_PRESSURE

    IMPORTING

      EX_PRESSURE_VOL       = p_vol

    EXCEPTIONS

      EXP1                  = 1

             .

    LV_PRESSURE_VOL = P_VOL.

        LO_EL_ND_TABLE->SET_ATTRIBUTE(

          NAME `PRESSURE_VOL`

          VALUE = LV_PRESSURE_VOL ).

       endif.

************

   LO_ND_ND_TABLE->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING TABLE = LT_ND_TABLE ).

   LOOP at LT_ND_TABLE into wa.

*    if wa-dip_hi is not INITIAL.

     if wa-WERKS is not INITIAL.

       insert ZSILO_CREAT from  wa.

     else.

       CLEAR wa.

     ENDIF.

ENDLOOP.

*********************************************************************

endmethod.

Accepted Solutions (0)

Answers (2)

Answers (2)

sudarmanikandan
Explorer
0 Kudos

Hello Tirup,

Answer to your questions.

1.  You can add the conditions to populate the 5th field based on the 4th field inside the LOOP.

LOOP at LT_ND_TABLE into wa.

    

     case wa-(4th field).

     when '1'.

      wa-(5th field) = "Val1".

      when '2'.

      wa-(5th field) = "Val2".

     when OTHERS.

    wa-(5th field) = "OTHERS".

     endcase.

    

     if wa-WERKS is not INITIAL.

       insert ZSILO_CREAT from  wa.

     else.

       CLEAR wa.

     ENDIF.

ENDLOOP.


2. To set the number of records needs to be displayed/extend the number of records in table.


For display only, you can set the number of visible row properties to -1. But it leads to performance issue.


To extend the number of rows, you can add a button to add a empty record at the end of table. when user clicks on the button, just write the below logic to add the record


DATA lo_table TYPE cl_wd_table.

* Pass the table name

lo_table ?= view->get_element( ID = 'name_of_table_in_the_view').

*Get the number of entries in table

*Add 1 to number of entries and pass it to below code

lo_table->SET_VISIBLE_ROW_COUNT(value = 'number of entries').

Hope this may help you.

Thanks,

Sudar


nishantbansal91
Active Contributor
0 Kudos

Dear Thirup,

Can you please elaborate  requirement.

As per my understanding you are facing issue while updating the Table ZSILO_CREATE.

because you are getting only the lead selected element. if you want to update the complete table you have to get the table in the component.

* get element via lead selection

   LO_EL_ND_FORM = LO_ND_ND_FORM->GET_ELEMENT( ).

* get all declared attributes

   LO_EL_ND_FORM->GET_STATIC_ATTRIBUTES(

     IMPORTING

       STATIC_ATTRIBUTES = LS_ND_FORM ).

   INSERT ZSILO_CREATE from LS_ND_FORM.

You have to use the below code for getting the table.

LO_ND_ND_TABLE->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING TABLE = LT_ND_TABLE)



Thanks

Nishant

Former Member
0 Kudos

Hi Nishant,


thanks for ur response....

I have two issues

1     Am trying  updating a ztable  though wd comp... here for exampl i have 5 fields and

       I feed 4 of them and last one should get based on the 4th field. and it should repeat for

       all records and save in ztable.......Am displaying an empty editable table to feed ztzble

2     in the out put table no of records should be extend as user requires to enter more records

       and for example visible row count minimum like 10 and should extenddd as user wish..

       here i used row count and visible row count properties but no use

        

      in this case how to insert new row dynamically  at run time... plz help me

nishantbansal91
Active Contributor
0 Kudos

Dear Thirup,

I am not able to understand your issue, I think you have to generate subroutine pool for this.

Please check the GENERATE SUBROUTINE POOL Statement.

Thanks

Nishant

Former Member
0 Kudos

hi guruss

in the below table i created a onenter  event for DIP_HI cell editor. i.e on enter for 6th col....

here based on DIP_ HI i need to get DIP_VOL.......onenter event working for 1st row only

onenter event not triggering from 2nd row  here how to capture onenter event for each cell in that column

or how to loop all recods to get next val based on previous val

plzzz help meeeeeeeee

sudarmanikandan
Explorer
0 Kudos

Hello Thirup,

As Nishant said, you can use the below code to get all entries from the table and populate the field.

LO_ND_ND_TABLE->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING TABLE = LT_ND_TABLE).


Based on the DIP_HI value, you can populate DIP_VOL values at runtime and update the entries in table.


On Enter event should work for all. It would be great, if you can provide the code written in the event block.


Thanks,

Sudar




Former Member
0 Kudos

hi Suda

code is below .......with this code am not getting value for 2nd record plzzzz check code

method ONACTIONONENTER_DIP .

***********************************************************************************************

   DATA LO_ND_ND_TABLE TYPE REF TO IF_WD_CONTEXT_NODE.

   DATA LO_EL_ND_TABLE TYPE REF TO IF_WD_CONTEXT_ELEMENT.

   DATA LS_ND_TABLE TYPE WD_THIS->ELEMENT_ND_TABLE.

   DATA LV_DIP_HI TYPE WD_THIS->ELEMENT_ND_TABLE-DIP_HI.

   DATA LV_LGORT TYPE WD_THIS->ELEMENT_ND_TABLE-LGORT.

   DATA LV_VOL_DIP TYPE WD_THIS->ELEMENT_ND_TABLE-VOL_DIP.

   TYPES : BEGIN OF TY_SILO,

     LGORT TYPE LGORT_D,

     DIP_HI TYPE ZDIPHI,

     VOL_DIP TYPE ZVOL_DIP,

     END OF TY_SILO.

   DATA  WA_SILO TYPE TY_SILO.

   DATA  IT TYPE STANDARD TABLE OF TY_SILO.

   DATA D_VOL TYPE ZVOL_DIP.

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

   LO_ND_ND_TABLE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_ND_TABLE ).

* get element via lead selection

   LO_EL_ND_TABLE = LO_ND_ND_TABLE->GET_ELEMENT( ).

* get single attribute

   LO_EL_ND_TABLE->GET_ATTRIBUTE(

     EXPORTING

       NAME `DIP_HI`

     IMPORTING

       VALUE = LV_DIP_HI ).

     LO_EL_ND_TABLE->GET_ATTRIBUTE(

     EXPORTING

       NAME `LGORT`

     IMPORTING

       VALUE = LV_LGORT ).

   IF LV_DIP_HI IS NOT INITIAL.

     SELECT SINGLE LGORT DIP_HI VOL_DIP

              FROM ZSILO_MASTER

              INTO WA_SILO

              WHERE LGORT = LV_LGORT  AND DIP_HI = LV_DIP_HI.

             D_VOL = WA_SILO-VOL_DIP.

             CLEAR WA_SILO.

              ENDIF.

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

   LO_ND_ND_TABLE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_ND_TABLE ).

* get element via lead selection

   LO_EL_ND_TABLE = LO_ND_ND_TABLE->GET_ELEMENT( ).

* @TODO fill attribute

   lv_vol_dip = D_VOL.

* set single attribute

   LO_EL_ND_TABLE->SET_ATTRIBUTE(

     NAME `VOL_DIP`

     VALUE = LV_VOL_DIP ).

**********************************************************************************

Former Member
0 Kudos

Actually the functionality is not looping for all records

bt its working for first record only

sudarmanikandan
Explorer
0 Kudos

Hello Thirup,

Please use the below code..

DATA LO_ND_ND_TABLE TYPE REF TO IF_WD_CONTEXT_NODE.

   DATA LO_EL_ND_TABLE TYPE REF TO IF_WD_CONTEXT_ELEMENT.

   DATA LS_ND_TABLE TYPE WD_THIS->ELEMENT_ND_TABLE.

   DATA LV_DIP_HI TYPE WD_THIS->ELEMENT_ND_TABLE-DIP_HI.

   DATA LV_LGORT TYPE WD_THIS->ELEMENT_ND_TABLE-LGORT.

   DATA LV_VOL_DIP TYPE WD_THIS->ELEMENT_ND_TABLE-VOL_DIP.

   TYPES : BEGIN OF TY_SILO,

     LGORT TYPE LGORT_D,

     DIP_HI TYPE ZDIPHI,

     VOL_DIP TYPE ZVOL_DIP,

     END OF TY_SILO.

   DATA  WA_SILO TYPE TY_SILO.

   DATA  IT TYPE STANDARD TABLE OF TY_SILO.

   DATA D_VOL TYPE ZVOL_DIP.

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

   LO_ND_ND_TABLE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_ND_TABLE ).

* get element via lead selection

   LO_EL_ND_TABLE = LO_ND_ND_TABLE->GET_ELEMENT( ).

* get single attribute

   LO_EL_ND_TABLE->GET_ATTRIBUTE(

     EXPORTING

       NAME `DIP_HI`

     IMPORTING

       VALUE = LV_DIP_HI ).

     LO_EL_ND_TABLE->GET_ATTRIBUTE(

     EXPORTING

       NAME `LGORT`

     IMPORTING

       VALUE = LV_LGORT ).

clear D_VOL.

   IF LV_DIP_HI IS NOT INITIAL.

     SELECT SINGLE LGORT DIP_HI VOL_DIP

              FROM ZSILO_MASTER

              INTO WA_SILO

              WHERE LGORT = LV_LGORT  AND DIP_HI = LV_DIP_HI.

             D_VOL = WA_SILO-VOL_DIP.

             CLEAR WA_SILO.

     ENDIF.

IF D_VOL IS NOT INITIAL.

* set single attribute

   LO_EL_ND_TABLE->SET_ATTRIBUTE(

     NAME `VOL_DIP`

     VALUE = D_VOL ).


ENDIF.


Thanks,

Sudar

Former Member
0 Kudos

HI SUdar,

Remains unchanged

first record k bt functionality nt workin for 2nd record on words

its nt looping...... how  to loop it  .......

or else how to capture that event to entair cell