04-25-2015 3:41 PM
Hello All,
I am using a function module in which I have declared a field symbol. In some cases, that field symbol does not have values. So it is giving dump when field symbol is not assigned.
That field symbol is being used at many places in the function module. So everywhere I cannot check IF <field-symbol> IS ASSIGNED.
Is there any way to control the logic so that it would not give dump even if field symbol is not assigned?
04-25-2015 3:52 PM
Hello Ankit,
Isn't checking once immediately after the assignment enough? I think it should be.
Thanks
Rajit
04-25-2015 4:13 PM
Hello Rajit,
Thnks for the reply.
but In that case it will skip the whole function module if it is not assigned.
In our case, we want to execute all the code other than passing the data from field symbol, if field symbol is not assigned.
04-25-2015 4:18 PM
Hi Ankit,
You can try -
TRY.
IF <fs_check> IS ASSIGNED.
ENDIF.
CATCH CX_SY_CONVERSION_ERROR into lo_exc.
data: lv_String type string.
lv_String = lo_Exc->get_text( ).
message lv_String type 'S'
ENDTRY.
BR,
Praveen
04-25-2015 4:36 PM
Hello Ankit,
My doubt is, why it will not be assigned?? I mean, are there some scenarios where it will not be assigned? If the assignment is happening inside some 'IF' condition then I'll probably suggest you to take it out making sure the field-symbol is assigned for sure.
Otherwise, wherever you are using the <FS> your'll have to check it if assigned or not which I think is tedious and unnecessary.
Thanks
Rajit
04-25-2015 5:27 PM
Yes, there are some scenarios where <FS> is not assigned. In other cases, it will be assigned.
04-25-2015 5:32 PM
Write your code properly so that the scenarios where the field symbol is not assigned don't run the code where it is used.
Perhaps if you shared the code, it would enable more helpful answers.
04-25-2015 5:44 PM
04-25-2015 9:15 PM
Do not ask for email ids on this site. Private sharing of information in not encouraged.
04-25-2015 5:14 PM
Hi ankit.
Try,
if sy-subrc = 0.
" pass the data from field symbols.
endif.
Hope it helpful,
Regards,
Venkat.V
04-25-2015 5:17 PM
If you're having to do IF <blah> IS ASSIGNED before each use of <blah> that signals very strongly that the program is badly written.
Hence the solution is to write the program better (more modularisation, no (or very much reduced) global data), not try and fix the symptom.
04-25-2015 6:11 PM
Hi Ankit,
Seems that you are changing an existing code. As suggested by Matthew that you need to modularise the code. If not then you can replace field-symbol with Work area but make sure that field symbol value is not changing any value in internal table.
The below scenario should not exist in your existing code.
E.g loop at it_tab1 assiging <FS_tab1>.
<FS_tab1>-val1 = 'ABC'.
Endloop.
Then only you can replace Field-symbol with work area.. This is one of the example.