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 not assigned

Former Member
0 Kudos

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?

11 REPLIES 11

former_member195431
Participant
0 Kudos

Hello Ankit,

Isn't checking once immediately after the assignment enough? I think it should be.

Thanks

Rajit

0 Kudos

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.

0 Kudos

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

0 Kudos

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

0 Kudos

Yes, there are some scenarios where <FS> is not assigned. In other cases, it will be assigned.

0 Kudos

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.

0 Kudos

Please send me ur email id...

0 Kudos

Do not ask for email ids on this site. Private sharing of information in not encouraged.

VenkatRamesh_V
Active Contributor
0 Kudos

Hi ankit.

Try,

if sy-subrc = 0.

" pass the data from field symbols.

endif.

Hope it helpful,

Regards,

Venkat.V

matt
Active Contributor
0 Kudos

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.

0 Kudos

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.