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: 

In FM SAVE_DATA invalid material no also showing SY-SUBRC = 0

Former Member
0 Kudos

Dear Friends,

I am uploading PO long text in MM02 by using fm 'SAVE_TEXT in my program.

Its woking fine.

if i give invalid material no as input in HEADDATA also showing sy-subrc = 0.

pls suggest'

1 ACCEPTED SOLUTION

JL23
Active Contributor
0 Kudos

It writes the data to STXH and STXL if you dont validate this yourself first.

I assume you have already written data with to these tables.

If you someday create a material having this number, then the text appears like a phantom.

Find those records and delete them.

3 REPLIES 3

Former Member
0 Kudos

Hi,

SAVE_TEXT is not directly linked to a PO. The link is created via the header data that you pass. As such, no validations are done on the data since SAVE_TEXT can be used to save data for several different types of texts.

You options is to put an condition before calling SAVE_TEXT that checks for the material.

Select single *
from MAKT
where matnr = my_material_no.
if sy-subrc ne 0.
     message e000(38) with 'Material does not exist'.
else.
   CALL FUNCTION 'SAVE_TEXT'
  EXPORTING
    header                = v_header
  tables
    lines                 = it_lines
 EXCEPTIONS
   ID                    = 1
   LANGUAGE              = 2
   NAME                  = 3
   OBJECT                = 4
   OTHERS                = 5
          .
IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif.

JL23
Active Contributor
0 Kudos

It writes the data to STXH and STXL if you dont validate this yourself first.

I assume you have already written data with to these tables.

If you someday create a material having this number, then the text appears like a phantom.

Find those records and delete them.

Former Member
0 Kudos

Hi ,

As suggested by our friend dsouzajovito , we need to check first for material existence and then pass to the function module as it is no way related to material change.

Thanks,

Srikanth.A