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

DOCUMENT NUMBER AFTER COMMIT IN BAPI

Former Member
0 Likes
1,118

Hi everybody.

Im using the bapi BAPI_ALM_NOTIF_CREATE to create a notification in SAP. After the process I only get a temporary notification number. After commit, could I get the real notification number in some way?

Regards and thank you so much

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
842

Hello,

You need to follow the sequence of BAPIS as below:



    CALL FUNCTION 'BAPI_ALM_NOTIF_CREATE'
      EXPORTING
        notif_type         = c_type
        notifheader        = x_header
      IMPORTING
        notifheader_export = x_imp_header   " Notif Number
      TABLES
        notitem            = t_notitem
        notifcaus          = t_notifcaus
        longtexts          = t_longtexts
        return             = t_return_create.

    SORT t_return_create BY type.
* If the error is returned, the same is sent back to MES
    READ TABLE t_return_create INTO x_return_create WITH KEY type = c_error.   " c_error = 'E'
    IF sy-subrc EQ 0.
      x_return_mes-type     = x_return_create-type.
      x_return_mes-message  = x_return_create-message.                   " Notification could not be created.
      APPEND x_return_mes TO t_return_mes.
      CLEAR  x_return_mes.
    ELSE.

* Changing the Status to In-Progress
      CALL FUNCTION 'BAPI_ALM_NOTIF_PUTINPROGRESS'
        EXPORTING
          number = x_imp_header-notif_no.

* Save the Notification. Else the nitification number is seen but not in the transaction.
      CALL FUNCTION 'BAPI_ALM_NOTIF_SAVE'
        EXPORTING
          number      = x_imp_header-notif_no
        IMPORTING
          notifheader = x_imp_header.

* Commit to Database
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.


Afte this you will get the actual number.

Hope this helps.

~Pranu

4 REPLIES 4
Read only

Former Member
0 Likes
842

Hi,

do you have a look into export parameter: NOTIFHEADER_EXPORT?

Regards, Dieter

Read only

Former Member
0 Likes
843

Hello,

You need to follow the sequence of BAPIS as below:



    CALL FUNCTION 'BAPI_ALM_NOTIF_CREATE'
      EXPORTING
        notif_type         = c_type
        notifheader        = x_header
      IMPORTING
        notifheader_export = x_imp_header   " Notif Number
      TABLES
        notitem            = t_notitem
        notifcaus          = t_notifcaus
        longtexts          = t_longtexts
        return             = t_return_create.

    SORT t_return_create BY type.
* If the error is returned, the same is sent back to MES
    READ TABLE t_return_create INTO x_return_create WITH KEY type = c_error.   " c_error = 'E'
    IF sy-subrc EQ 0.
      x_return_mes-type     = x_return_create-type.
      x_return_mes-message  = x_return_create-message.                   " Notification could not be created.
      APPEND x_return_mes TO t_return_mes.
      CLEAR  x_return_mes.
    ELSE.

* Changing the Status to In-Progress
      CALL FUNCTION 'BAPI_ALM_NOTIF_PUTINPROGRESS'
        EXPORTING
          number = x_imp_header-notif_no.

* Save the Notification. Else the nitification number is seen but not in the transaction.
      CALL FUNCTION 'BAPI_ALM_NOTIF_SAVE'
        EXPORTING
          number      = x_imp_header-notif_no
        IMPORTING
          notifheader = x_imp_header.

* Commit to Database
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.


Afte this you will get the actual number.

Hope this helps.

~Pranu

Read only

Former Member
0 Likes
842

As per my understanding temporary notification number and real notification number will be same .

And also notification number is avaliable in various paramaters of BAPI_ALM_NOTIF_CREATE. PLease check

Read only

Former Member
0 Likes
842

Thanks a lot Pranu Pranu!!! You solved my problem!!!!