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 Symbols and form parameters

Former Member
0 Kudos
303

Good day to all,

I am trying to change a parameter into a SAP form with a field-symbol but I have a problem when it comes the time to assign it.

Of course, because it is a SAP program, I can't change the original code and I'm using an user-exit but the export of this User-exit is not quite changing what I want to change (but it is the closest one). I was suggested to use a field-symbol to change the values into the SAP structure directly. I was shown an example on another program and it seemed to work fine but it was on a global data and not a changing parameter. It seems that because I would assign my field-symbols to a changing parameter, I get a sy-subrc = 4. Let me show you a bit of code that I have. I will write my comments in bold and the code will be in normal settings

FORM customer_exit_pai CHANGING p_cobl TYPE cobl.

DATA: l_ci_cobl TYPE bapicobl_ci.

  • Don't call exit if there are no customer fields

IF flg_ci_exists IS INITIAL.

PERFORM check_ci_cobl_exists.

ENDIF.

CHECK flg_ci_exists = 'Y'.

MOVE-CORRESPONDING p_cobl TO l_ci_cobl. "#EC ENHOK

CLEAR sy-subrc.

CALL CUSTOMER-FUNCTION '002'

EXPORTING

i_cobl = p_cobl (This is the parameter I want to change. A few validations makes me do some necessary changes)

CHANGING

e_cobl_cust = l_ci_cobl

EXCEPTIONS

send_message = 1

error_message = 2

OTHERS = 3.

IF sy-subrc = 0.

MOVE-CORRESPONDING l_ci_cobl TO p_cobl. "#EC ENHOK

ELSE.

flg_error_in_check = 'X'.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

CLEAR flg_error_in_check.

IF sy-msgty CA 'WSI'.

MOVE-CORRESPONDING l_ci_cobl TO p_cobl. "#EC ENHOK

ENDIF.

ENDIF.

ENDFORM.

Of course, the actual problem is that SAP function doesn't return the modifications I would like to do in that parameters so this is why I tried to call a field-symbol on this parameter to change a data or two. Here the code inside the include of the function module

DATA: va_text(40) TYPE c VALUE '(LKACBF03)P_COBL'.

FIELD-SYMBOLS: <fs_cobl> TYPE ANY.

Here are some various codes to verify what I received in that module function (i_cobl) that I transfered into wa_cobl for some needed modifications that I won't add here because it is unnecessary.

ASSIGN (va_text) TO <fs_cobl>.

IF <fs_cobl> IS ASSIGNED.

<fs_cobl> = wa_cobl.

ENDIF.

Now here comes the problem... When I do the assign, the field-symbol assignation gives a sy-subrc of 4 and, of course, the line <fs_cobl> = wa_cobl doesn't happen. Is it possible to help me on that assignation if it possible or tell me if it is not possible to assign a field-symbol on a changing parameters of a function?

Thank you very much for your kind help.

1 ACCEPTED SOLUTION

krishnendu_laha
Active Contributor
0 Kudos
107

Hello,

You can assign values to global work area / internal table in this way...please check 'P_COBL' is local / global..

Thanks

Krish

1 REPLY 1

krishnendu_laha
Active Contributor
0 Kudos
108

Hello,

You can assign values to global work area / internal table in this way...please check 'P_COBL' is local / global..

Thanks

Krish