cancel
Showing results for 
Search instead for 
Did you mean: 

how to create and use a node globally as well as internal table

Former Member
0 Kudos

HI,

Kindly let me know how can I create a node & internal table globally and which I can use them in various methods in view and controller as well, if u can provide an example it could be very help full.

my requirment is uploading a multiple files in wdp ABAP for this I just followd the link below

http://wiki.sdn.sap.com/wiki/display/WDABAP/UploadandDownloadfilesinWebdynproABAP

which for single upload and for making this for multiple upload I need a node could be usefull globally or a IT please check my code below

DATA lo_nd_n_upload TYPE REF TO if_wd_context_node.

DATA lo_el_n_upload TYPE REF TO if_wd_context_element.

DATA ls_n_upload TYPE wd_this->element_n_upload.

DATA lo_nd_n_file_download TYPE REF TO if_wd_context_node.

DATA lt_n_file_download TYPE wd_this->elements_n_file_download.

data ls_file_upload TYPE ZFILE_UPLOAD1.

  • ZFILE_UPLOAD_1 = wd_componentcontroller->Elements_ZFILE_UPLOAD_1.

t_file_upload = ig_componentcontroller->ITAB1.

  • t_file_upload = wd_this->zfile_upload1.

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

lo_nd_n_file_download = wd_context->get_child_node( name = wd_this->wdctx_n_file_download ).

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

lo_nd_n_upload = wd_context->get_child_node( name = wd_this->wdctx_n_upload ).

  • get element via lead selection

lo_el_n_upload = lo_nd_n_upload->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_n_upload IS not INITIAL.

  • get all declared attributes

lo_el_n_upload->get_static_attributes(

IMPORTING

static_attributes = ls_n_upload ).

  • ls_n_upload will contain the File name file type and file contents *

ls_n_upload-file_size = xstrlen( ls_n_upload-file_content ).

ls_file_upload-FILE_NAME = ls_n_upload-FILE_NAME.

ls_file_upload-FILE_TYPE = ls_n_upload-FILE_TYPE.

ls_file_upload-FILE_SIZE = ls_n_upload-FILE_SIZE.

ls_file_upload-FILE_CONTENTS = ls_n_upload-FILE_CONTENT.

append ls_file_upload to t_file_upload.

clear ls_file_upload.

lo_nd_n_file_download->bind_table( new_items = t_file_upload set_initial_elements = abap_true ).

ENDIF.

so here I would like use t_file_upload(node or IT ) to use globaly which can keep the previous data and I can add the existing data and in another method I would like to submit the data in t_file_upload to table

Regards

raj

Accepted Solutions (0)

Answers (1)

Answers (1)

ChandraMahajan
Active Contributor
0 Kudos

Hi,

use component contoller to create node that has global visiblity within WD component.

Thanks,

Chandra

Former Member
0 Kudos

Hi Chandra,

can u tell me how can because I created IT and node in Compcontroller and trying access in view, where its throwing error some where wrong with my code...can I expect any code example.

Regards

Raj

ChandraMahajan
Active Contributor
0 Kudos

Hi,

you need to map the component controller context node to the view context...

refer,

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e00ccb45-05c6-2c10-3088-e5d611839...

Thanks,

Chandra

Former Member
0 Kudos

Hi,

Sorry this link not helpfull to me, in my logic I need a node or IT than can defined globally with out loosing its previous data for that purpose I createda node in my program

data t_file_upload type->Elements_ZFILE_UPLOAD_1. its in my action method when I click action it would creates and holds data and again clicks on the same action for multple upload this method calls again and t_file_upload is re initilizing again so its loosing previous record.

could tell me how can I declare the IT globally

Thaanks.

Raj

ChandraMahajan
Active Contributor
0 Kudos

Hi,

In that case define gt_file_upload as an attribute in the Attributes sectio of the view.

then you can have

t_file_upload [ ] = wd_this->gt_file_upload [ ] . "here set ur Internal table from values of global table

IF t_file_upload [ ] IS INITIAL. "first time

***logic to fill t_file_upload and then set the global table as below,

wd_this->gt_file_upload [ ] = t_file_upload [ ].

ENDIF.

I hope this will be helpful for you.

Thanks,

Chandra

Edited by: Chandrashekhar Mahajan on Oct 6, 2011 4:49 PM

Former Member
0 Kudos

Hi Chandra,

Resloved, I createa table type in SE11 by giving my table name as a line type and I used that as a Global IT in view "attributes" tab and I made the my code as follows its working now

DATA lo_nd_n_upload TYPE REF TO if_wd_context_node.

DATA lo_el_n_upload TYPE REF TO if_wd_context_element.

DATA ls_n_upload TYPE wd_this->element_n_upload.

DATA lo_nd_n_file_download TYPE REF TO if_wd_context_node.

DATA lt_n_file_download TYPE wd_this->elements_n_file_download.

data ls_file_upload TYPE ZFILE_UPLOAD1.

data t_file_upload TYPE standard table of ZFILE_UPLOAD1.

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

lo_nd_n_file_download = wd_context->get_child_node( name = wd_this->wdctx_n_file_download ).

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

lo_nd_n_upload = wd_context->get_child_node( name = wd_this->wdctx_n_upload ).

  • get element via lead selection

lo_el_n_upload = lo_nd_n_upload->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_n_upload IS not INITIAL.

  • get all declared attributes

lo_el_n_upload->get_static_attributes(

IMPORTING

static_attributes = ls_n_upload ).

  • ls_n_upload will contain the File name file type and file contents *

ls_n_upload-file_size = xstrlen( ls_n_upload-file_content ).

ls_file_upload-FILE_NAME = ls_n_upload-FILE_NAME.

ls_file_upload-FILE_TYPE = ls_n_upload-FILE_TYPE.

ls_file_upload-FILE_SIZE = ls_n_upload-FILE_SIZE.

ls_file_upload-FILE_CONTENTS = ls_n_upload-FILE_CONTENT.

append ls_file_upload to ME->wd_this->gt_file_upload .

clear ls_file_upload.

lo_nd_n_file_download->bind_table( ME->wd_this->gt_file_upload ).

endif.

thanks for the support.

Regards

Raj