Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Error in writing a Currency field.

Former Member
0 Kudos
208

Hi All,

i had written a program to download the whole Table on the application server, it is a genralised program if i enter any table on the selection screen it will be downloaded n application server.

i am creating a dynamic internal table and then putting a select using opn cursor technique, and then downloading the same on the application server by opn data set.

issue i am facing with certain table like dfkkop which has the currency field, so while looping i am moving the whole work area into a string and then tranfering it. but for DFKKOP i am not able to transfer as it is giving me dump because of currency field.

so how can i write the whole work area to a string variable with out geting dump, if some one has idea regarding that pleaase share.

Regards,

Himanshu Sharma

3 REPLIES 3

Former Member
0 Kudos
73

Hi

Probably it need to transfer field by field

Max

kesavadas_thekkillath
Active Contributor
0 Kudos
73

Himanshu,

Apply this logic



DATA:w_ref TYPE REF TO data,
     w_l TYPE REF TO data,
     wf_data_str    TYPE REF TO data,
     wf_ltype TYPE c,
     wi_count TYPE i,
     wf_string TYPE string,
     wf_length TYPE i,
     wf_maximum TYPE i,
     wf_total_fields TYPE i,
     i_comp TYPE cl_abap_structdescr=>component_table,
     wf_type_struct TYPE REF TO cl_abap_structdescr,
     wa_comp LIKE LINE OF i_comp,
     wi_index TYPE i.

FIELD-SYMBOLS:<fs_t> TYPE table,
              <fs_l> TYPE ANY,
              <fs_s> TYPE ANY,
              <fs_wa> TYPE ANY,
              <fs_tr> TYPE ANY.

PARAMETERS:pa_tab TYPE tabname.

CREATE DATA w_ref TYPE TABLE OF (pa_tab).
ASSIGN w_ref->* TO <fs_t>.
CREATE DATA w_l LIKE LINE OF <fs_t>.
ASSIGN w_l->* TO <fs_l>.

SELECT * FROM (pa_tab) INTO TABLE <fs_t> UP TO 10 ROWS.
CHECK <fs_t>[] IS NOT INITIAL.

DESCRIBE FIELD <fs_l> TYPE       wf_ltype
                           COMPONENTS wi_count.

wf_maximum = 0.
wf_total_fields = wi_count.

WHILE wi_count GT 0.
  wi_index = sy-index.
  ASSIGN COMPONENT wi_index OF STRUCTURE <fs_l> TO <fs_s>.
  IF sy-subrc EQ 0.
    DESCRIBE FIELD <fs_s> TYPE          wf_ltype
                          OUTPUT-LENGTH wf_length.
    IF wf_maximum LT wf_length.
      wf_maximum = wf_length.
    ENDIF.
  ENDIF.
  wi_count = wi_count - 1.
ENDWHILE.

CLEAR:wa_comp,i_comp[].
wa_comp-name = 'FIELD'(005).
wa_comp-type ?= cl_abap_elemdescr=>get_c( wf_maximum ).
APPEND wa_comp TO i_comp.

TRY.
  wf_type_struct = cl_abap_structdescr=>create( p_components = i_comp ).
  CATCH cx_sy_struct_creation.
ENDTRY.

CREATE DATA: wf_data_str TYPE HANDLE wf_type_struct.

ASSIGN wf_data_str->* TO <fs_wa>.

LOOP AT <fs_t> ASSIGNING <fs_l>.
  DO.
    ASSIGN COMPONENT sy-index OF STRUCTURE <fs_l> TO <fs_s>.
    IF sy-subrc = 0.
      ASSIGN COMPONENT 'FIELD' OF STRUCTURE <fs_wa> TO <fs_tr>.
      IF sy-subrc = 0.
        <fs_tr> = <fs_s>.
        CONCATENATE wf_string <fs_tr> INTO wf_string SEPARATED BY '|'.
      ENDIF.
    ELSE.
      EXIT.
    ENDIF.
  ENDDO.
ENDLOOP.

Former Member
0 Kudos
73

Thanks for the reply guys, i found a FM which convert the whole work area to charter field.

FM : C147_WORKAREA_TO_CHARFIELD

Himanshu