Skip to Content
author's profile photo Former Member
Former Member

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

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on May 17, 2015 at 12:32 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 17, 2015 at 02:00 PM

    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


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.