cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP Webdynpro: Creating a table on webdynpro screen to enter new data.

former_member386290
Participant
0 Kudos

Hello Experts,

Does anyone know, how to create a table on webdynpro screen that can be used to enter new data in database?

I have tried to create a Table UI element (with Standard Cell Editor as Input Field) but it is "Display only" if there is no data in the table. This means, while you can use it to modify the data if some data already exist, but you cannot use it to enter new data if no data already exist. What I am looking for is something similar to a Table Control (or Step-Loop) functionalty of a traditional (non webdynpro) SAP screen. How to achieve this in Webdynpro for ABAP?

Thanks in advance.

ABAPer

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

To create table in edit mode if no data exist in table.

You put condition like that, if data exist write your code.

data not exist write below code to display empty records with editable fields.

Cehck this...

DATA: lt_sflight TYPE if_main=>elements_sflight,
            wa_sflight TYPE if_main=>element_sflight,
            lv TYPE REF TO if_wd_context_node.
 
  DO 10 TIMES.
    APPEND wa_sflight TO lt_sflight.
  ENDDO.
  lv = wd_context->get_child_node( name = 'SFLIGHT' ).
  lv->bind_table( new_items = lt_sflight ).

Cheers,

Kris.

former_member386290
Participant
0 Kudos

Thanks to Sarvanan, Srinivas and Kris for their replies.

Sarvanan - I have not fully understood the document which is in the link you gave. But as I understand about ALVs on Webdynpros, one has to press 'Create Row' or 'Append Row' button everytime they want to create a new entry. They cannot keep on enetring values without pressing these buttons. Please do correct me if I am wrong.

Srinivas and Kris - Problem with your solutions is that it will only show me editable 10 rows if I have created initailly 10 blank rows in advance in the code. User cannot scroll down and create more rows and I cannot create hundreds of empty rows in advance as it does not sound a professional approach.

Anybody else please?

Thank you

ABAPer

saravanan_narayanan
Active Contributor
0 Kudos

yes, you need to press create button for creating new records, and if I'm not wrong this is the SAP standard of creating records in the table ( like pressing NEW icon or Create button or '+' icon ).

BR, Saravanan

former_member199125
Active Contributor
0 Kudos

Hi...

yes using my approach, you can assign 10 or any number rows. Just check your requirement how many records user have to create each time..

And i am sure you can scroll with out any problem. Try to enter data in table and check. If table visible row count is 10 , then obviously u wont have scrolling. if number of rows are more than visible row count then you wil have scrolling.

Or else place one button , in that write code to add 10 blank records..runtime he canhave as many records he want.

In webdynpro this is solution I know, if i am wrong let us wait for others.

Regards

Srinivas

sahai
Contributor
0 Kudos

Hi...

> yes using my approach, you can assign 10 or any number rows. Just check your requirement how many records user have to create each time..

> And i am sure you can scroll with out any problem. Try to enter data in table and check. If table visible row count is 10 , then obviously u wont have scrolling. if number of rows are more than visible row count then you wil have scrolling.

>

> Or else place one button , in that write code to add 10 blank records..runtime he canhave as many records he want.

> In webdynpro this is solution I know, if i am wrong let us wait for others.

>

> Regards

> Srinivas

hi,

the suggestion by you is correct by why we will provide the same .....is a question.....if i was given a chance in this scenario i would provide him an option to upload excel sheet wherein all the data would be maintained and entered by user in an easier way...

give a thought.....else wise if the user is willing to go via a cumbersome process you can use the method given by ssrinivas..

thanks and regards,

Sahai.s

former_member199125
Active Contributor
0 Kudos

Even if no data is not there, you can pass blank work areas to table, so now table will blank rows where you can enter the data even if previous data is not there.

below is the sample code to get blank rows in table in order to enter data.

DATA LO_ND_N_EDUCATION1 TYPE REF TO IF_WD_CONTEXT_NODE.

DATA LO_EL_N_EDUCATION1 TYPE REF TO IF_WD_CONTEXT_ELEMENT.

DATA LS_N_EDUCATION1 TYPE WD_THIS->ELEMENT_N_EDUCATION1.

  • navigate from <CONTEXT> to <N_EDUCATION1> via lead selection

LO_ND_N_EDUCATION1 = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_N_EDUCATION1 ).

DATA: ET_DATA TYPE WD_THIS->ELEMENTS_N_EDUCATION1,

EW_DATA TYPE WD_THIS->ELEMENT_N_EDUCATION1.

DO 10 TIMES.

APPEND EW_DATA TO ET_DATA.

ENDDO.

  • get element via lead selection

LO_EL_N_EDUCATION1 = LO_ND_N_EDUCATION1->GET_ELEMENT( ).

LO_ND_N_EDUCATION1->BIND_TABLE( NEW_ITEMS = ET_DATA SET_INITIAL_ELEMENTS = ABAP_FALSE ).

now table will have 10 rows, here node name is N_education1.

Thanks and REgards

Srinivas

saravanan_narayanan
Active Contributor
0 Kudos

ALV suits your requirement better. But for writing the data into the DDIC table you need to write logic of inserting/updating data from context node to DDIC table.

have a look at the following article for ALV integration

[http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/80a3de18-ee00-2d10-bfb3-946d7e00fd91]

BR, Saravanan