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

Error Handling

Former Member
0 Likes
791

I would like to take my error records into a notepad.

Here is my code...

the internal table "it_hrpe_relaq" contains the final data which needs to go in using the function module "RHPP_Q_PROFILE_WRITE'"---

CALL FUNCTION 'RHPP_Q_PROFILE_WRITE'

EXPORTING

plvar = c_plvar

otype = c_otype

objid = l_pernr

vtask = 'D'

TABLES

profile = it_hrpe_relaq[].

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

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

endif.

endat.

  • ENDLOOP.

  • ENDIF.

CLEAR: it_hrpe_relaq,

it_tra_data.

REFRESH: it_hrpe_relaq.

  • ENDAT.

ENDLOOP.

I have done the following too---

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_error.

I mean ask the user to give the flat file name.

Would apppreciate if anyone can guide around to capture the error records or which ever fail into a internal table and then I will be able to download using GUI_DOWNLOAD.

1 ACCEPTED SOLUTION
Read only

former_member761936
Active Participant
0 Likes
712

Hi ,

In the function module 'RHPP_Q_PROFILE_WRITE' , there is a table parameter called error_profile.Use that to get errros.

then loop through that populate error internal table and download.No need to use BDCMSGCOLL here.



  CALL FUNCTION 'RHPP_Q_PROFILE_WRITE'
         EXPORTING
              PLVAR                 = PLVAR
              OTYPE                 = OTYPE
              OBJID                 = SOBID
              VTASK                 = 'B'
         TABLES
              PROFILE               = ADD_QUALIPROF
              ERR_PROFILE           = ERROR_PROFILE
              CHANGE_PROFILE        = CHANGE_QUALIPROF
         EXCEPTIONS
              NO_AUTHORITY          = 1
              ERROR_DURING_INSERT   = 2
              WRONG_OTYPE           = 3
              OBJECT_NOT_FOUND      = 4
              OBJECT_REQUIRED       = 5
              NO_SCALE_DEFINED      = 6
              SCALE_NOT_CLEAR       = 7
              TIME_NOT_VALID        = 8
              PROFICIENCY_NOT_VALID = 9
              WRONG_DATE_FORMAT     = 10
              UNDEFINED             = 11
              OTHERS                = 12.
    IF SY-SUBRC = 0.                                        "OK
      READ TABLE CHANGE_QUALIPROF INDEX 1 TRANSPORTING NO FIELDS.
      IF SY-SUBRC = 0.
*     Qualifikation wurde aufgrund einer Gültigkeit abgegrenzt und
*     in Tabelle change_qualiprof angehängt.
        LOOP AT CHANGE_QUALIPROF .
          CHANGE_PROFILE-OBJ_ID   = CHANGE_QUALIPROF-TBJID.
          CHANGE_PROFILE-BEGDA    = CHANGE_QUALIPROF-VBEGD.
          CHANGE_PROFILE-ENDDA    = CHANGE_QUALIPROF-VENDD.
          CHANGE_PROFILE-RATING   = CHANGE_QUALIPROF-PROFCY.
          APPEND CHANGE_PROFILE.
        ENDLOOP.
      ENDIF.
      READ TABLE CHANGE_PROFILE INDEX 1 TRANSPORTING NO FIELDS.
      IF SY-SUBRC <> 0.
        RETURN-TYPE = 'S'.
        RETURN-NUMBER = '600'.         "Erfolgreich beendet
      ELSE.
*  Erfolgreich beendet und Qualifikationen wurden automatisch abgegrenzt
        RETURN-TYPE = 'S'.
        RETURN-NUMBER = '602'.
        ABGEGRENZT = 'X'.
      ENDIF.
    ELSE.                              "IF sy-subrc <> 0  (Not OK)
    add_error = 'X'.
        CASE SY-SUBRC.
          WHEN 1.
            RETURN-TYPE   = 'E'.      "no authority
            RETURN-NUMBER = '603'.    "Dazu haben Sie keine Berechtigung
          WHEN 2.
            RETURN-TYPE   = 'E'.
           RETURN-NUMBER = '604'. "Fehler beim Anlegen der Qualifikation
          WHEN 3.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '605'.     "Ungültiger Objekttyp
          WHEN 4.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '606'.     "Objekt nicht vorhanden
          WHEN 5.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '606'.     "Objekt nicht vorhanden
          WHEN 6.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '607'.     "Es ist keine Skala definiert
          WHEN 7.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '608'.     "Die Skala ist nicht eindeutig
          WHEN 8.
            RETURN-TYPE   = 'E'.
       RETURN-NUMBER = '609'. "Der Verknüpfungszeitraum ist nicht gültig
          WHEN 9.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '610'.     "Die Ausprägung ist nicht gültig
          WHEN 10.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '611'.     "Falsches Datumsformat
          WHEN 11.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '612'.     "Sonstiger Fehler
          WHEN OTHERS.
            RETURN-TYPE   = 'E'.
      RETURN-NUMBER = '619'. "Zu den Eingaben wurden keine Daten gefunde
        ENDCASE.                       "case sy-subrc > 0
*       Err_Profile-table get filled
        READ TABLE ERROR_PROFILE INDEX 1 TRANSPORTING NO FIELDS.
        IF SY-SUBRC = 0.
          LOOP AT ERROR_PROFILE.
            ERR_PROFILE-OBJ_ID   = ERROR_PROFILE-TBJID.
            ERR_PROFILE-BEGDA    = ERROR_PROFILE-VBEGD.
            ERR_PROFILE-ENDDA    = ERROR_PROFILE-VENDD.
            ERR_PROFILE-RATING   = ERROR_PROFILE-PROFCY.
            APPEND ERR_PROFILE.
          ENDLOOP.


6 REPLIES 6
Read only

Former Member
0 Likes
712

Hi all,

Is the following alright???????

data: begin of t_error .

include structure hrpe_relaq.

include structure bdcmsgcoll.

data: end of t_error.

-


and then at the function module.......

CALL FUNCTION 'RHPP_Q_PROFILE_WRITE'

EXPORTING

plvar = c_plvar

otype = c_otype

objid = l_pernr

vtask = 'D'

TABLES

profile = it_hrpe_relaq[].

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

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

MOVE-CORRESPONDING it_hrpe_relaq TO t_error.

MOVE-CORRESPONDING t_bdcmsgcoll TO t_error.

APPEND t_error.

endif.

endat.

  • ENDLOOP.

  • ENDIF.

CLEAR: it_hrpe_relaq,

it_tra_data.

REFRESH: it_hrpe_relaq.

  • ENDAT.

ENDLOOP.

Inputs please...

Regards,

Hari

Edited by: HARI KIRAN REDDY on Aug 12, 2008 10:56 AM

Edited by: HARI KIRAN REDDY on Aug 12, 2008 10:58 AM

Read only

0 Likes
712

Hi all,

Lets take my scenario in a much more simple way.

I have a final internal table filled with data.

I will be using XYZ function module to load the data.

Some records failed.

Need to push them into a flat file.

I am not talking about error handling in call transaction.

We have enough examples on SDN.

Inputs please.

Warm regards,

Hari Kiran

Read only

former_member761936
Active Participant
0 Likes
713

Hi ,

In the function module 'RHPP_Q_PROFILE_WRITE' , there is a table parameter called error_profile.Use that to get errros.

then loop through that populate error internal table and download.No need to use BDCMSGCOLL here.



  CALL FUNCTION 'RHPP_Q_PROFILE_WRITE'
         EXPORTING
              PLVAR                 = PLVAR
              OTYPE                 = OTYPE
              OBJID                 = SOBID
              VTASK                 = 'B'
         TABLES
              PROFILE               = ADD_QUALIPROF
              ERR_PROFILE           = ERROR_PROFILE
              CHANGE_PROFILE        = CHANGE_QUALIPROF
         EXCEPTIONS
              NO_AUTHORITY          = 1
              ERROR_DURING_INSERT   = 2
              WRONG_OTYPE           = 3
              OBJECT_NOT_FOUND      = 4
              OBJECT_REQUIRED       = 5
              NO_SCALE_DEFINED      = 6
              SCALE_NOT_CLEAR       = 7
              TIME_NOT_VALID        = 8
              PROFICIENCY_NOT_VALID = 9
              WRONG_DATE_FORMAT     = 10
              UNDEFINED             = 11
              OTHERS                = 12.
    IF SY-SUBRC = 0.                                        "OK
      READ TABLE CHANGE_QUALIPROF INDEX 1 TRANSPORTING NO FIELDS.
      IF SY-SUBRC = 0.
*     Qualifikation wurde aufgrund einer Gültigkeit abgegrenzt und
*     in Tabelle change_qualiprof angehängt.
        LOOP AT CHANGE_QUALIPROF .
          CHANGE_PROFILE-OBJ_ID   = CHANGE_QUALIPROF-TBJID.
          CHANGE_PROFILE-BEGDA    = CHANGE_QUALIPROF-VBEGD.
          CHANGE_PROFILE-ENDDA    = CHANGE_QUALIPROF-VENDD.
          CHANGE_PROFILE-RATING   = CHANGE_QUALIPROF-PROFCY.
          APPEND CHANGE_PROFILE.
        ENDLOOP.
      ENDIF.
      READ TABLE CHANGE_PROFILE INDEX 1 TRANSPORTING NO FIELDS.
      IF SY-SUBRC <> 0.
        RETURN-TYPE = 'S'.
        RETURN-NUMBER = '600'.         "Erfolgreich beendet
      ELSE.
*  Erfolgreich beendet und Qualifikationen wurden automatisch abgegrenzt
        RETURN-TYPE = 'S'.
        RETURN-NUMBER = '602'.
        ABGEGRENZT = 'X'.
      ENDIF.
    ELSE.                              "IF sy-subrc <> 0  (Not OK)
    add_error = 'X'.
        CASE SY-SUBRC.
          WHEN 1.
            RETURN-TYPE   = 'E'.      "no authority
            RETURN-NUMBER = '603'.    "Dazu haben Sie keine Berechtigung
          WHEN 2.
            RETURN-TYPE   = 'E'.
           RETURN-NUMBER = '604'. "Fehler beim Anlegen der Qualifikation
          WHEN 3.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '605'.     "Ungültiger Objekttyp
          WHEN 4.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '606'.     "Objekt nicht vorhanden
          WHEN 5.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '606'.     "Objekt nicht vorhanden
          WHEN 6.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '607'.     "Es ist keine Skala definiert
          WHEN 7.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '608'.     "Die Skala ist nicht eindeutig
          WHEN 8.
            RETURN-TYPE   = 'E'.
       RETURN-NUMBER = '609'. "Der Verknüpfungszeitraum ist nicht gültig
          WHEN 9.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '610'.     "Die Ausprägung ist nicht gültig
          WHEN 10.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '611'.     "Falsches Datumsformat
          WHEN 11.
            RETURN-TYPE   = 'E'.
            RETURN-NUMBER = '612'.     "Sonstiger Fehler
          WHEN OTHERS.
            RETURN-TYPE   = 'E'.
      RETURN-NUMBER = '619'. "Zu den Eingaben wurden keine Daten gefunde
        ENDCASE.                       "case sy-subrc > 0
*       Err_Profile-table get filled
        READ TABLE ERROR_PROFILE INDEX 1 TRANSPORTING NO FIELDS.
        IF SY-SUBRC = 0.
          LOOP AT ERROR_PROFILE.
            ERR_PROFILE-OBJ_ID   = ERROR_PROFILE-TBJID.
            ERR_PROFILE-BEGDA    = ERROR_PROFILE-VBEGD.
            ERR_PROFILE-ENDDA    = ERROR_PROFILE-VENDD.
            ERR_PROFILE-RATING   = ERROR_PROFILE-PROFCY.
            APPEND ERR_PROFILE.
          ENDLOOP.


Read only

0 Likes
712

Hi,

Narendra,

I was going through the function module and I found the same.

here is my code now...

This this will do..

Data:it_hrpe_relaq TYPE STANDARD TABLE OF _relaq WITH HEADER LINE,

it_error TYPE STANDARD TABLE OF hrpe_relaq WITH HEADER LINE.

At function module----

CALL FUNCTION 'RHPP_Q_PROFILE_WRITE'

EXPORTING

plvar = c_plvar

otype = c_otype

objid = l_pernr

vtask = 'D'

TABLES

profile = it_hrpe_relaq[]

err_profile = it_error[].

  • CHANGE_PROFILE =

  • EXCEPTIONS

  • NO_AUTHORITY = 1

  • ERROR_DURING_INSERT = 2

  • WRONG_OTYPE = 3

  • OBJECT_NOT_FOUND = 4

  • OBJECT_REQUIRED = 5

  • NO_SCALE_DEFINED = 6

  • SCALE_NOT_CLEAR = 7

  • TIME_NOT_VALID = 8

  • PROFICIENCY_NOT_VALID = 9

  • WRONG_DATE_FORMAT = 10

  • UNDEFINED = 11

  • OTHERS = 12

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

I believe this internal table it_error will now capture the error records and I just need to pass it_error in GUI_DOWNLOAD and have it in my notepad.

Confirm please Narendra.

Regards,

Hari Kiran

Read only

former_member761936
Active Participant
0 Likes
712

Hi Hari,

It will Do.You can proceed with your code

Read only

Former Member
0 Likes
712

This message was moderated.