Displaying internal table contents into Textedit UI element in webdynpro using string_table type

By Deepan Ignaatious, Kaavian systems

Scenario: In this example, I demonstrate on how to store and display an internal table contents into Textedit UI element in webdynpro using string_table type. By using the string_table type the internal table values are displayed nicely in table format in TEXTEDIT UI element.String_table type is used because TEXTEDIT UI element cannot be bonded to internal table directly.

Steps in short:

The steps to create Screen Variants are as follows.

  • Create a webdynpro component

  • Create a node with attribute of string_table type

  • Bind the attribute to the value of the textedit ui element

  • Pass the internal table contents to the attribute

  • Output is displayed

Steps:

1.  Create a webdynpro component ZD_TABLE_INTEXTEDIT in SE80.

2.  Double click the MAIN view and Go to Context tab and create a node with an attribute of following type.

Node: TXT

Cardinality: 1...n

Attribute: TEXT

Type: String_table

3.  Go to layout tab and create a TEXTEDIT UI element under rootelementcontainer and bind the value of the UI element to ‘text’ attribute defined in the context.  

4.  Attributes of the TEXTEDIT UI Element used are shown below.

5. Go to methods tab and in WDDOINIT method create an internal table and set the values of the internal table to the text attribute defined in the context as Shown below.

5. The coding used in the WDDOINIT method is given below for reference.

  DATA LO_ND_TXT TYPE REF TO IF_WD_CONTEXT_NODE.
  
DATA LO_EL_TXT TYPE REF TO IF_WD_CONTEXT_ELEMENT.
  
DATA LS_TXT TYPE WD_THIS->ELEMENT_TXT.
  
DATA LV_TEXT TYPE WD_THIS->ELEMENT_TXT-TEXT.
  
DATA LV_STRING TYPE STRING.
  
DATA :BEGIN OF WA  ,
    A 
TYPE MARA-MATNR,
    B 
TYPE MAKT-MAKTX,
  
END OF WA.
  
DATA IT LIKE TABLE OF WA.
  WA-A = 
'10'.
  WA-B = 
'sdlsa'.
  
APPEND WA TO IT.
  WA-A = 
'20'.
  WA-B = 
'ball'.
  
APPEND WA TO IT.
  WA-A = 
'30'.
  WA-B = 
'bat'.
  
APPEND WA TO IT.

 
"Moving values to the LV_text which of type string_table type
  
LOOP AT IT INTO WA.
    
CONCATENATE WA-A WA-B INTO LV_STRING SEPARATED BY space.
    
APPEND LV_STRING TO LV_TEXT.
  
ENDLOOP.

* navigate from <CONTEXT> to <TXT> via lead selection
  LO_ND_TXT = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_TXT ).
* get element via lead selection
  LO_EL_TXT = LO_ND_TXT->GET_ELEMENT( ).
* set single attribute
  LO_EL_TXT->SET_ATTRIBUTE(
    NAME =  
`TEXT`
    
VALUE = LV_TEXT ).

Output:

The internal table values are displayed nicely in table format in TEXTEDIT UI element.  

SAP Virtual/Onsite Trainings

Document Categories:

What's New?

Contribute?

Sample Specs

What's Hot?

Web Dynpro for ABAP Tutorials 


Join the Mailing List
Enter name and email address below:
Name:
Email:
Subscribe  Unsubscribe 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image