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

Catching Error Message

Former Member
0 Likes
8,106

Hi,

Question : could you please tell me how to catch footer error message?

Background :

I am working with FM L_TO_CREATE_SINGLE .

This FM has so many exceptions and I am catching those in my custom program.

the problem is FM is throwing error message while it executes and simply coming out of my custom program and displaying error message at footer so I am not able to catch error message.

Please help me how to catch this error and see my code below

CALL FUNCTION 'L_TO_CREATE_SINGLE'

EXPORTING

I_LGNUM = '620'

I_BWLVS = '999'

I_MATNR = WA_RECORD_OUT-MATNR

I_WERKS = WA_RECORD_OUT-WERKS

I_ANFME = WA_PHY_INV_HIS-QUANTITY

I_ALTME = WA_PHY_INV_HIS-UNIT_OF_MEASURE

I_SQUIT = 'X'

I_VLTYP = WA_RECORD_OUT-LGTYP

I_VLPLA = WA_RECORD_OUT-LGPLA

I_VLENR = WA_PHY_INV_HIS-STO_UNIT

I_NLTYP = WA_PHY_INV_HIS-STO_TYPE

I_NLPLA = WA_PHY_INV_HIS-STO_BIN

I_COMMIT_WORK = 'X'

I_BNAME = SY-UNAME

I_KOMPL = 'X'

IMPORTING

E_TANUM = I_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

OTHERS = 34 .

IF SY-SUBRC <> 0.

CASE sy-subrc.

WHEN 1. MESSAGE = 'no_to_created'.

WHEN 2. MESSAGE = 'bwlvs_wrong' .

WHEN 3. MESSAGE = 'betyp_wrong'.

WHEN 4. MESSAGE = 'benum_missing'.

WHEN 5. MESSAGE = 'betyp_missing'.

WHEN 6. MESSAGE = 'foreign_lock'.

WHEN 7. MESSAGE = 'vltyp_wrong'.

WHEN 8. MESSAGE = 'vlpla_wrong'.

WHEN 9. MESSAGE = 'vltyp_missing'.

WHEN 10. MESSAGE = 'nltyp_wrong'.

WHEN 11. MESSAGE = 'nlpla_wrong'.

WHEN 12. MESSAGE = 'nltyp_missing'.

WHEN 13. MESSAGE = 'rltyp_wrong'.

WHEN 14. MESSAGE = 'rlpla_wrong'.

WHEN 15. MESSAGE = 'rltyp_missing'.

WHEN 16. MESSAGE = 'squit_forbidden'.

WHEN 17. MESSAGE = 'manual_to_forbidden'.

WHEN 18. MESSAGE = 'letyp_wrong'.

WHEN 19. MESSAGE = 'vlpla_missing'.

WHEN 20. MESSAGE = 'nlpla_missing'.

WHEN 21. MESSAGE = 'sobkz_wrong'.

WHEN 22. MESSAGE = 'sobkz_missing'.

WHEN 23. MESSAGE = 'sonum_missing'.

WHEN 24. MESSAGE = 'bestq_wrong'.

WHEN 25. MESSAGE = 'lgber_wrong'.

WHEN 26. MESSAGE = 'xfeld_wrong'.

WHEN 27. MESSAGE = 'date_wrong'.

WHEN 28. MESSAGE = 'drukz_wrong'.

WHEN 29. MESSAGE = 'ldest_wrong'.

WHEN 30. MESSAGE = 'update_without_commit'.

WHEN 31. MESSAGE = 'no_authority'.

WHEN 32. MESSAGE = 'material_not_found'.

WHEN 33. MESSAGE = 'lenum_wrong'.

WHEN 34. MESSAGE = 'ERROR_MESSAGE'.

WHEN OTHERS.

message id sy-msgid type sy-msgty number sy-msgno with

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

ENDCASE.

Thanks

SB

1 ACCEPTED SOLUTION
Read only

arseni_gallardo
Active Participant
0 Likes
3,124

Sarath,

There is something you can do to catch unexpected error messages: use the error_message addition of the CALL FUNCTION statement.

Read this: [http://help.sap.com/abapdocu_70/en/ABAPCALL_FUNCTION_PARAMETER.htm]

In your particular case just add this to the list of exceptions

ERROR_MESSAGE = 99

and then


CASE sy-subrc.
 ....
   WHEN 99 . MESSAGE = 'unexpected error message'.

Edited by: Arseni Gallardo on Oct 12, 2011 8:46 PM

7 REPLIES 7
Read only

Former Member
0 Likes
3,124

Well, what error is ist showing?

Rob

Read only

0 Likes
3,124

Rob here is the error message

Storage bin A-002 in storage type EWG does not exist (check your entry)

Message no. L3004

Thanks

SB

Read only

0 Likes
3,124

There are notes for this message. Have you looked for them?

Rob

Read only

0 Likes
3,124

No I didn't look for notes, But i can do that.

are the notes you are talking about to through errors so that we can capture in our custom programs? if that is not correct we may get other errors too correct...

Read only

0 Likes
3,124

I don't know - maybe the first thing to do here is to correct the error.

Rob

Read only

arseni_gallardo
Active Participant
0 Likes
3,125

Sarath,

There is something you can do to catch unexpected error messages: use the error_message addition of the CALL FUNCTION statement.

Read this: [http://help.sap.com/abapdocu_70/en/ABAPCALL_FUNCTION_PARAMETER.htm]

In your particular case just add this to the list of exceptions

ERROR_MESSAGE = 99

and then


CASE sy-subrc.
 ....
   WHEN 99 . MESSAGE = 'unexpected error message'.

Edited by: Arseni Gallardo on Oct 12, 2011 8:46 PM

Read only

0 Likes
3,124

Hi I have resloved it myself. here is the working code, thanks for all your help

CALL FUNCTION 'L_TO_CREATE_SINGLE'
          EXPORTING
            I_LGNUM                     = '620'
            I_BWLVS                     = '999'
            I_MATNR                     = WA_RECORD_OUT-MATNR
            I_WERKS                     = WA_RECORD_OUT-WERKS
            I_ANFME                     = WA_PHY_INV_HIS-QUANTITY
            I_ALTME                     = WA_PHY_INV_HIS-UNIT_OF_MEASURE
           I_SQUIT                     = 'X'
           I_VLTYP                     = WA_RECORD_OUT-LGTYP
           I_VLPLA                     = WA_RECORD_OUT-LGPLA
           I_VLENR                     = WA_PHY_INV_HIS-STO_UNIT
           I_NLTYP                     = WA_PHY_INV_HIS-STO_TYPE
           I_NLPLA                     = WA_PHY_INV_HIS-STO_BIN
           I_COMMIT_WORK               = 'X'
           I_BNAME                     = SY-UNAME
           I_KOMPL                     = 'X'
         IMPORTING
           E_TANUM                     = I_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               = 99
           OTHERS                      = 34.

        IF SY-SUBRC NE 0.
          CALL FUNCTION 'FORMAT_MESSAGE'
            EXPORTING
              ID        = SY-MSGID
              LANG      = '-D'
              NO        = SY-MSGNO
              V1        = SY-MSGV1
              V2        = SY-MSGV2
              V3        = SY-MSGV3
              V4        = SY-MSGV4
            IMPORTING
              MSG       = MESSAGE
            EXCEPTIONS
              NOT_FOUND = 1
              OTHERS    = 2.
       ENDIF.

Edited by: Rob Burbank on Oct 12, 2011 3:44 PM