cancel
Showing results for 
Search instead for 
Did you mean: 

any alternative for this codding.

Former Member
0 Kudos

hello Tech Experts,

I'm developing a simple application in wd for uploading text file into ztable. I've found some sources to implement, I had a doubt in the following code



CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
  EXPORTING
  in_xstring = l_xstring
  IMPORTING
  out_string = l_string.


  SPLIT l_string AT cl_abap_char_utilities=>newline INTO TABLE i_data.

* Bind With table Element.

  LOOP AT i_data INTO l_string.

  SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.

 

READ TABLE fields INTO lv_field INDEX 1.
  fs_table-name = lv_field.

  READ TABLE fields INTO lv_field INDEX 2.
  fs_table-age = lv_field.


  APPEND fs_table TO t_table1.

  ENDLOOP.

  lo_nd_sflight = wd_context->get_child_node( 'DATA_TAB' ).
  lo_nd_sflight->bind_table( t_table1 ).

this code works fine, But inside the loop we are reading the value field by field using index in this case it has just 2 records, what if they are n number of records. Do I have to use those read statements for 'n' times.

please help me if there is any alternative solution for this.

thank you,

Regards,

Nagendra

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Alternative can be this for N-Fields.

SPLIT l_string AT cl_abap_char_utilities=>newline INTO TABLE i_data.

LOOP AT i_data INTO l_string.

SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO

                                   <workarea>-field1

                                   <workarea>-field2

                                   <workarea>-field3

                                   <workarea>-field4

                                   <workarea>-field5

                                   <workarea>-field6

                                             :

                                             :

append <workarea> to <itab>.

clear <workarea>.                        

ENDLOOP.

Note : <itab> is an internal table where your required fields are declared.

Hope this helps you.

Thanks

KH

Former Member
0 Kudos

hi KH,

thank you, I'l try this .

regards,

Nagendra

Former Member
0 Kudos

Hi KH,

sorry to bug you again, I've one more question is it possible to download that table again into a text file and PDF in web dynpro. If yes please provide me any sample code or point me to any other resource

Thanks a ton.

Regards,

Nagendra

Former Member
0 Kudos

Hi,

You can download the contents using cl_wd_runtime_services=>attach_file_to_response( ) method by passing respective MIME types.

For reference you can check 'DEMO_ADOBE_OFFLINE' wdp component.


Thanks

KH

Former Member
0 Kudos

hello KH,

I copied this code from standard one

data:

     lr_pdf_node type ref to if_wd_context_node,

     pdf         type xstring.

   lr_pdf_node = wd_context->get_child_node( wd_this->wdctx_UPLOAD_EXCEL ).

   lr_pdf_node->get_attribute( exporting name = 'FILE_DATA' importing value = pdf ).

 

cl_wd_runtime_services=>attach_file_to_response(

     i_filename      = 'DemoAdobeOffline.pdf'

     i_content       = pdf

     i_mime_type     = 'application/pdf'

     i_in_new_window = ABAP_FALSE

     i_inplace       = ABAP_false ).

I would like to download the pdf in local system. but they didn't specify any location to download in that method. can you please help me.

Thank you,

Regards,

Nagendra

Former Member
0 Kudos

Hi,

In  i_filename  parameter, you can specify the path.

Thanks

KH

Former Member
0 Kudos

Hi KH,

I did that too.

cl_wd_runtime_services=>attach_file_to_response(

     i_filename      = 'C:\DemoAdobeOffline.pdf'

     i_content       = pdf

     i_mime_type     = 'application/pdf'

     i_in_new_window = ABAP_FALSE

     i_inplace       = ABAP_false ).

It didn't work. Actually my requirement is to download an internal table to pdf format.

please help.

Regards

nagendra

Former Member
0 Kudos

Hi,

Does anyone have an idea why is it not working.Please Help

Regards,

Nagendra

Answers (0)