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

Function module L_TO_CREATE_SINGLE

Former Member
0 Likes
3,765

Hi,

I am using L_TO_CREATE_SINGLE function module in loop when the input parameters are correct for this function module its creating to succesfully. but when input parameters are not correct its totally comming out of the program.

my requirement is to skip that error record and process next record.

can any body help me in this regard

Regards

ramesh

1 ACCEPTED SOLUTION
Read only

valter_oliveira
Active Contributor
0 Likes
2,446

Hello Ramesh.

It happens because that FM throw error messages. It's the same behaviour of FM L_TO_CREATE_MULTIPLE.

Solutions:

- prevent all the errors that can occur before calling the FM

- use batch input

- create a ZL_TO_CREATE_SINGLE, replacing error message by bapireturn entries

Regards,

Valter Oliveira.

3 REPLIES 3
Read only

valter_oliveira
Active Contributor
0 Likes
2,447

Hello Ramesh.

It happens because that FM throw error messages. It's the same behaviour of FM L_TO_CREATE_MULTIPLE.

Solutions:

- prevent all the errors that can occur before calling the FM

- use batch input

- create a ZL_TO_CREATE_SINGLE, replacing error message by bapireturn entries

Regards,

Valter Oliveira.

Read only

leif_almgren
Participant
2,446

This is a very late reply, but this is how I solved this problem. The trick is to add the general exception "error_message", this will handle any messages that are created inside the call, without exiting the program. Then you can read the SY-MSG* system fields to get the actual error message and take the neccessary action.

CALL FUNCTION 'L_TO_CREATE_SINGLE'
    EXPORTING
      i_lgnum               = iv_lgnum
      i_bwlvs               = '999'
      i_matnr               = iv_matnr
      i_werks               = iv_werks
      i_charg               = iv_charg
      i_anfme               = lv_qty
      i_altme               = lv_unit
      i_vltyp               = iv_vltyp
      i_vlpla               = iv_vlpla
      i_nltyp               = iv_nltyp
      i_nlpla               = iv_nlpla
    IMPORTING
      e_tanum               = ev_tanum
    EXCEPTIONS
      no_to_created         = 1
      bwlvs_wrong           = 2
      betyp_wrong           = 3
      benum_missing         = 4
      betyp_missing         = 5
      foreign_lock          = 6
      vltyp_wrong           = 7
      vlpla_wrong           = 8
      vltyp_missing         = 9
      nltyp_wrong           = 10
      nlpla_wrong           = 11
      nltyp_missing         = 12
      rltyp_wrong           = 13
      rlpla_wrong           = 14
      rltyp_missing         = 15
      squit_forbidden       = 16
      manual_to_forbidden   = 17
      letyp_wrong           = 18
      vlpla_missing         = 19
      nlpla_missing         = 20
      sobkz_wrong           = 21
      sobkz_missing         = 22
      sonum_missing         = 23
      bestq_wrong           = 24
      lgber_wrong           = 25
      xfeld_wrong           = 26
      date_wrong            = 27
      drukz_wrong           = 28
      ldest_wrong           = 29
      update_without_commit = 30
      no_authority          = 31
      material_not_found    = 32
      lenum_wrong           = 33
      error_message         = 34
      OTHERS                = 35.

  IF sy-subrc NE 0.
    IF sy-subrc NE 34.
*    Error message based on exception
      MESSAGE e111(zrf) WITH sy-subrc.
    ELSE.
*     Read error message from SY-MSG* fields
      MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
  ENDIF.

Hope this will help others with the same issue.

/Leif

Read only

0 Likes
2,446

Great answer, it helped me with the same issue I had, thanks