Application Development and Automation 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: 
Read only

Help with BADI

Former Member
0 Likes
747

Hi all,

I am trying to implement a BADI which reads the internal table ct_data[] with some manipulation in the internal table and saves it back to the application.

Following is my code

method IF_UJ_CUSTOM_LOGIC~EXECUTE.
 
  FIELD-SYMBOLS: <ls_rec> TYPE ANY,
        <ls_result_rec> TYPE ANY,
        <ls_time> TYPE ANY,
        <ls_signeddata> TYPE ANY,
        <lt_final> TYPE STANDARD TABLE,
        <lt_rptcurrency> TYPE ANY,
        <lt_P_CC> TYPE ANY,
        <lt_time> TYPE ANY,
        <lt_append> TYPE ANY,
        <lt_datasrc> TYPE ANY,
        <lt_P_Acc> TYPE ANY,
        <lt_Category> TYPE ANY,
        <lt_P_DataSrc> TYPE ANY,
        <lt_P_Activity> TYPE ANY.
  BREAK-POINT.
  LOOP AT ct_data ASSIGNING <ls_rec>.
*    <ls_result_rec> = <ls_rec>.
    ASSIGN COMPONENT 'TIME' OF STRUCTURE <ls_rec> TO <lt_time>.
    ASSIGN COMPONENT 'P_CC' OF STRUCTURE <ls_rec> TO <lt_P_CC>.
    ASSIGN COMPONENT 'RPTCURRENCY' OF STRUCTURE <ls_rec> TO <lt_rptcurrency>.
    ASSIGN COMPONENT 'P_DATASRC' OF STRUCTURE <ls_rec> TO <lt_P_DataSrc>.
    ASSIGN COMPONENT 'P_ACTIVITY' OF STRUCTURE <ls_rec> TO <lt_P_Activity>.
    ASSIGN COMPONENT 'P_ACC' OF STRUCTURE <ls_rec> TO <lt_P_Acc>.
    ASSIGN COMPONENT 'CATEGORY' OF STRUCTURE <ls_rec> TO <lt_Category>.
    ASSIGN COMPONENT 'SIGNEDDATA' OF STRUCTURE <ls_rec> TO <ls_signeddata>.
    <lt_Category> = 'FORECAST'.
    APPEND <ls_rec> TO <lt_final>.
  endloop.
 
  LOOP AT <lt_final> ASSIGNING <lt_append>.
    APPEND <lt_append> TO ct_data.
  ENDLOOP.
 
endmethod.

It gives me shot dump after line APPEND <ls_rec> TO <lt_final>.

Error: Field symbol has not yet been assigned.

Please help,

Diksha.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
696

Diksha,

You should read online help on the ABAP statement CREATE DATA.

If I remember correctly, the help page has a simple example that is easy to understand.

Hi all,

I am trying to implement a BADI which reads the internal table ct_data[] with some manipulation in the internal table and saves it back to the application.

Following is my code

method IF_UJ_CUSTOM_LOGIC~EXECUTE.
 
  FIELD-SYMBOLS: <ls_rec> TYPE ANY,
        <ls_result_rec> TYPE ANY,
        <ls_time> TYPE ANY,
        <ls_signeddata> TYPE ANY,
        <lt_final> TYPE STANDARD TABLE,
        <lt_rptcurrency> TYPE ANY,
        <lt_P_CC> TYPE ANY,
        <lt_time> TYPE ANY,
        <lt_append> TYPE ANY,
        <lt_datasrc> TYPE ANY,
        <lt_P_Acc> TYPE ANY,
        <lt_Category> TYPE ANY,
        <lt_P_DataSrc> TYPE ANY,
        <lt_P_Activity> TYPE ANY.
  BREAK-POINT.
  LOOP AT ct_data ASSIGNING <ls_rec>.
*    <ls_result_rec> = <ls_rec>.
    ASSIGN COMPONENT 'TIME' OF STRUCTURE <ls_rec> TO <lt_time>.
    ASSIGN COMPONENT 'P_CC' OF STRUCTURE <ls_rec> TO <lt_P_CC>.
    ASSIGN COMPONENT 'RPTCURRENCY' OF STRUCTURE <ls_rec> TO <lt_rptcurrency>.
    ASSIGN COMPONENT 'P_DATASRC' OF STRUCTURE <ls_rec> TO <lt_P_DataSrc>.
    ASSIGN COMPONENT 'P_ACTIVITY' OF STRUCTURE <ls_rec> TO <lt_P_Activity>.
    ASSIGN COMPONENT 'P_ACC' OF STRUCTURE <ls_rec> TO <lt_P_Acc>.
    ASSIGN COMPONENT 'CATEGORY' OF STRUCTURE <ls_rec> TO <lt_Category>.
    ASSIGN COMPONENT 'SIGNEDDATA' OF STRUCTURE <ls_rec> TO <ls_signeddata>.
    <lt_Category> = 'FORECAST'.
    APPEND <ls_rec> TO <lt_final>.
  endloop.
 
  LOOP AT <lt_final> ASSIGNING <lt_append>.
    APPEND <lt_append> TO ct_data.
  ENDLOOP.
 
endmethod.

It gives me shot dump after line APPEND <ls_rec> TO <lt_final>.

Error: Field symbol has not yet been assigned.

Please help,

Diksha.

2 REPLIES 2
Read only

Former Member
0 Likes
697

Diksha,

You should read online help on the ABAP statement CREATE DATA.

If I remember correctly, the help page has a simple example that is easy to understand.

Read only

Former Member
0 Likes
696

Hi Diksha,

The reason you are getting this error is because you are trying append to the FieldSymbol <lt_final> without having assigned it to anything.

APPEND <ls_rec> TO <lt_final>.

First assign the FieldSymbol <lt_final> to an internal table then use this code.

Regards,

Jovito