cancel
Showing results for 
Search instead for 
Did you mean: 

Action for upload of files to table

former_member210563
Participant
0 Kudos

Hi,

I have an action used by a button to upload files. I am reprogramming it to Work with internal tables instead of a transparent table with the uploaded files.

The problem is that it does not add the files to the internal table, so there is always only one record in the itab. I must be doing something wrong here. If you can see it, please let me know. See source in the attached file.

Thanks; Peter

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member210563
Participant
0 Kudos

Thanks all,

The essence of this is that I have to reorganize the code from using a z-table in dictionary to use oi only internal tabels.

This Means that I have a record in LT_FILE_UPLOADS of the type TY_FILE_UPLOAD that is defined like my z-table, but now as a type.

Before when I used the z-table I could select into the LT_N_FILE_DOWNLOAD without problems. If I now try to move the data from LT_FILE_UPLOADS to LT_N_FILE_DOWNLOAD, I get a type mismatch and for that I would like advice. Hence the attached file.

Thanks.

Former Member
0 Kudos

Hi,

Can you check if attributes of LT_FILE_UPLOADS and LT_FILE_DOWNLOAD are same type?.

Thanks

KH

ramakrishnappa
Active Contributor
0 Kudos

Hi Peter,

Refer the below document in which I have explained the similar requirement of yours.

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Hi Peter,

You mean if file1 is already attached/exists in internal table and if you  attach new file say file2,

Does it should add file1,file2 to your internal tab?.

Thanks

KH

former_member210563
Participant
0 Kudos

Yes, I have a table UI element that shows the uploaded files. The cardinality of the node is 0.n.

If I debug, I see that the previous file is "overwritten" by file no. 2 and there is always only 1 file in the table element.....?

Former Member
0 Kudos

Hi Peter,

To achieve your requirment follow the below steps.

1) On your button action, first read the table UI element into one temp itab using GET_STATIC_ATTRIBUTES_TABLE.

i.e LO_ND_<NODE>->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING TABLE = <TEMP_TAB>).

2) Now if <TEMP_TAB1> is not initial i.e if already files are attached, just try to APPEND your new attachment to <TEMP_TAB1>

3) Now your <TEMP_TAB1> consists of already attached file and new files which are attached.Just try to bind this <TEMP_TAB1> to your internal table.

Check the attachment which contains code for your reference.

Thanks

KH

former_member210563
Participant
0 Kudos

Hi,

Could you make the attachment as .TXT ?

Thanks.

Peter

Former Member
0 Kudos

Hi,

PFA of code in .TXT format.

Thanks

KH

former_member210563
Participant
0 Kudos

HI,

Thanks, however how is gt_v_attachments declared ?

Peter

Former Member
0 Kudos

Hi ,

GT_V_ATTACHMENTS is table type of my FILE UPLOAD node.

Thanks

KH

Former Member
0 Kudos

I do something similar in several applications - works fine. get back to me if there is not enough clues in method below


my zzfile is defined as

FILENAME ZZFILENAME STRING 0 0 Filename

FILETYPE ZZFILETYPE STRING 0 0 Filetype

FILELEN ZZFILELEN CHAR 10 0 Filelength

FILE_CONTENT ZZFILE_CONTENT RAWSTRING 0 0 Filecontent

______________________________ ______________________________ ____________________________________________________________________________________________________________________________________ ______ ______ ____________________________________________________________

method on_click_object.



  data:

    lv_col_id like r_param->column,

    lv_indx like r_param->index,

    lv_attr like r_param->attribute.



  lv_col_id = r_param->column.

  lv_indx = r_param->index.

  lv_attr = r_param->attribute.



  if r_param->column = 'SEQNR'.

    data:

      lo_nd_f type ref to if_wd_context_node,

      lo_el_f type ref to if_wd_context_element,

      ls_f type zzfile.



    " get the file uploaded

    lo_nd_f = go_main_context->get_child_node( 'F_UPLOAD' ).

    lo_el_f = lo_nd_f->get_element).

    lo_el_f->get_static_attributes(

      importing

        static_attributes = ls_f ).



    if ls_f is initial.

      " report message

      im_message_manager->report_attribute_error_message(

        exporting

          message_text   = 'No file to upload has been selected'

          element        = lo_el_f

          attribute_name = 'FILE_UP' ).

      return.

    endif.



    ls_f-filelen = xstrlen( ls_f-file_content ).



    data:

      lv_filename type dsvasdocid,

      lv_filetype type dsvasdocid.



    lv_filename = ls_f-filename.

    call function 'DSVAS_DOC_FILENAME_SPLIT'

      exporting

        pf_docid     = lv_filename

      importing

        pf_filename  = lv_filename

        pf_extension = lv_filetype.



    ls_f-filename = lv_filename.



    " update the object table with the file uploaded

    data:

      lo_nd_object type ref to if_wd_context_node,

      lo_el_object type ref to if_wd_context_element,

      ls_object type zautoauth_object_str.



    lo_nd_object = go_main_context->get_child_node( 'ZAUTOAUTH_OBJECT' ).

    lo_el_object = lo_nd_object->get_element( lv_indx ).

    lo_el_object->get_static_attributes(

      importing

        static_attributes = ls_object ).



    move-corresponding ls_f to ls_object.

    lo_el_object->set_static_attributes(

      exporting

        static_attributes = ls_object ).

    lo_el_object->set_changed_by_client( ).

  endif.


endmethod.