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: 

Field Symbol Has not yet been assigned

0 Kudos

I am trying to use table from another report program as in the following:

REPORT  ZSAM3.

 TYPES: BEGIN OF ty_report,
          rec_acc TYPE skont,
          vendor TYPE LFA1-LIFNR,
          jan_deb TYPE BSEG-WRBTR,
          jan_cred TYPE BSEG-WRBTR,
          feb_deb TYPE BSEG-WRBTR,
          feb_cred TYPE BSEG-WRBTR,
          mar_deb TYPE BSEG-WRBTR,
          mar_cred TYPE BSEG-WRBTR,
          apr_deb TYPE BSEG-WRBTR,
          apr_cred TYPE BSEG-WRBTR,
          may_deb TYPE BSEG-WRBTR,
          may_cred TYPE BSEG-WRBTR,
          jun_deb TYPE BSEG-WRBTR,
          jun_cred TYPE BSEG-WRBTR,
          jul_deb TYPE BSEG-WRBTR,
          jul_cred TYPE BSEG-WRBTR,
          aug_deb TYPE BSEG-WRBTR,
          aug_cred TYPE BSEG-WRBTR,
          sep_deb TYPE BSEG-WRBTR,
          sep_cred TYPE BSEG-WRBTR,
          oct_deb TYPE BSEG-WRBTR,
          oct_cred TYPE BSEG-WRBTR,
          nov_deb TYPE BSEG-WRBTR,
          nov_cred TYPE BSEG-WRBTR,
          dec_deb TYPE BSEG-WRBTR,
          dec_cred TYPE BSEG-WRBTR,
          acc_bal_deb TYPE BSEG-WRBTR,
          acc_bal_cred TYPE BSEG-WRBTR,
        END OF ty_report,
        tt_report TYPE TABLE OF ty_report.

DATA:  lt_report TYPE tt_report,
       lv_ukurs type tcurr-ukurs,
       Tcurr1 type tcurr,
       fieldname(4) type c,
       fnamedebit(20) type c,
       fnamecredit(20) type c.

FIELD-SYMBOLS: <fs_rep> LIKE LINE OF lt_report.
 select single ukurs from tcurr
        into lv_ukurs
        where fcurr = 'EUR'
        and   tcurr = 'AUD'. "<- your  local currency

DATA lr_pay_data              TYPE REF TO data.

FIELD-SYMBOLS: <lt_pay_data>   TYPE ANY TABLE,
               <pos_data> type any.

  cl_salv_bs_runtime_info=>set(
    EXPORTING display  = abap_false
              metadata = abap_false
              structure = ''
              data     = abap_true ).

SUBMIT RFKSLD00 via SELECTION-SCREEN and return.
TRY.
    ASSIGN lr_pay_data->* TO <lt_pay_data>.
>>> cl_salv_bs_runtime_info=>get_data(
      IMPORTING t_data = <lt_pay_data> ).
  CATCH cx_salv_bs_sc_runtime_info.
    MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
ENDTRY.

LOOP AT <lt_pay_data> ASSIGNING <pos_data>.

 APPEND INITIAL LINE to lt_report ASSIGNING <fs_rep>.
 MOVE-CORRESPONDING <pos_data> TO <fs_rep>.

WRITE: / <pos_data>.

ENDLOOP.

Write: 'Program End!'.

I am getting the following runtime error:

you attenpted to access an anassigned field symbol (data segment 12)

Maybe (as suggested by arrows in the code) that <'lt_pay_data'> has not been initialized or assigned but I do not know how assign any table type variable.

5 REPLIES 5

Sandra_Rossi
Active Contributor

Of course LR_PAY_DATA was never assigned a bound reference (to an existing data object), so ASSIGN fails and the field symbol is not assigned (sy-subrc = 4).

Based on your other recent questions, I know that you'd like to use the method GET_DATA_REF of class CL_SALV_BS_RUNTIME_INFO, but your "old" SAP ERP version does not have it, so you're trying with the only existing method which exists, GET_DATA.

The only solution left to you is to declare the internal table as done in the concerned program (I just looked inside the code of RFKSLD00, there are 2 ALVs, I assume it's the first one, you're lucky, they are typed globally):

DATA: gt_fkont     TYPE STANDARD TABLE OF foap_s_rfksld00_list1.
DATA: gt_fkont_sum TYPE STANDARD TABLE OF foap_s_rfksld00_list1.

cl_salv_bs_runtime_info=>get_data(
      IMPORTING t_data = GT_FKONT ).

And that's all.

0 Kudos

I'll try your current suggestion and hope this resolves it all.

0 Kudos

I need the monat field (reporting period) but it is not in the specified table

0 Kudos

So, you want the "MONAT" field, as first asked in this question in SCN and the same one in stackoverflow (different answers).

But your current question is different here, and is answered.

I will answer a generic answer in your original question.

Please close this one.

p244500
Active Contributor

Hi,

I will give you another sample code just try it. Its work for me. . You have to make sure data is available whatever the parameter when your passing with submit. If the data not available system will give you dump.

PROGRAM:test.

DATA : i_selection  TYPE STANDARD TABLE OF rsparams ,
       wa_selection TYPE  rsparams,
       lr_pay_data  TYPE REF TO data.

FIELD-SYMBOLS : <lt_pay_data> TYPE ANY TABLE ,
                <ls_pay_data> TYPE any.

REFRESH : i_selection[] .

CLEAR : wa_selection.
wa_selection-selname = 'LIFNR'.
wa_selection-kind    = 'S'.
wa_selection-sign    = 'I'.
wa_selection-option  = 'EQ'.
wa_selection-low     = '60000193' .
*wa_selection-high = '99999999' .
APPEND wa_selection TO i_selection.
CLEAR wa_selection.

wa_selection-selname = 'BUKRS'.
wa_selection-kind    = 'S'.
wa_selection-sign    = 'I'.
wa_selection-option  = 'EQ'.
wa_selection-low     = '1006' .
APPEND wa_selection TO i_selection.
CLEAR wa_selection.

wa_selection-selname = 'GJAHR'.
wa_selection-kind    = 'S'.
wa_selection-sign    = 'I'.
wa_selection-option  = 'EQ'.
wa_selection-low     = '2019' .
APPEND wa_selection TO i_selection.
CLEAR wa_selection.

cl_salv_bs_runtime_info=>set(
EXPORTING display = abap_false
metadata = abap_false
data = abap_true ).

SUBMIT RFKSLD00 WITH SELECTION-TABLE i_selection AND RETURN.
TRY.
    cl_salv_bs_runtime_info=>get_data_ref(
    IMPORTING r_data = lr_pay_data ).
    IF lr_pay_data IS NOT INITIAL.
      ASSIGN lr_pay_data->* TO <lt_pay_data>.
      IF <lt_pay_data> IS ASSIGNED.
*        Insert your logic
*
*
*
        CLEAR : lr_pay_data.
        REFRESH : <lt_pay_data>[].
      ENDIF.
    ENDIF.
  CATCH cx_salv_bs_sc_runtime_info.
    MESSAGE 'Unable to retrieve ALV data' TYPE 'E'.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).