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: 

how to return FI document number from SAP..?

Former Member
0 Kudos

Hi Gurus,

I have scenario here where in I have written a BDC program for transaction FV50L to park an FI document and then later made it is a function module.The FM is able to park the document from within SAP.. as i tested it...but i as it is a RFC enabled module it will be called from outside SAP...now how can i return the document number generated after parking to the non sap system...

I am using CALL TRANSACTION and transferring messages into a table of type BDCMSGCOLL..

Can any of u gurus provide me detail insight into this how it can be done....code samples will be helpful as i am still in a learning phase of ABAP...

<b><REMOVED BY MODERATOR></b>

Cheers:

Sam

Message was edited by:

Alvaro Tejada Galindo

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

You can pass the values in the FM interafce after reading the data from the BDCMSGCOLL table?

Cheers

VJ

10 REPLIES 10

Former Member
0 Kudos

Hi,

You can pass the values in the FM interafce after reading the data from the BDCMSGCOLL table?

Cheers

VJ

0 Kudos

Hi,

I am not sure where will be this value that i have to pick....i mean where in BDCMSGCOLL will be the document number generated after parking....

Please provide some inputs

Cheers:

Sam

0 Kudos

Hi,

You need to write code like this in Function module and DOCNUM will be your exporting document number from fm.


read table bdcmdgcoll with key MSGTYP ='S'
                               msgid = '<find the message id >
                               msgnr = '<find the message number>

if sy-subrc eq 0.
   move bdcmsgcoll-msgv1 to docnum.
endif.

0 Kudos

Hi,

When the document number is created or when the business document is posted in SAP the BDCMSGCOLL will have a Success message and the document number will be stored in the MSGV1 variables.

Hope this helps

Cheers

VJ

0 Kudos

I would return the entire contents of BDCMSGCOLL to the calling program and let it sort things out. There may be error messages that have to be handled.

Rob

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try something like this to send message to BDCMSGCOLL while using CALL TRANSACTION.


...

CALL TRANSACTION 'FV50L' USING IT_BDCDATA
                         MODE  C_MODE
                         UPDATE C_UDPATE
                         MESSAGES INTO IT_BDCMSGCOLL.

LOOP AT IT_BDCMSGCOLL.
  CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
      ID                   = IT_BDCMSGCOLL-MSGID
      LANG                 = IT_BDCMSGCOLL-MSGSPRA
      NO                   = IT_BDCMSGCOLL-MSGNR
      V1                   = IT_BDCMSGCOLL-MSGV1
      V2                   = IT_BDCMSGCOLL-MSGV2
      V3                   = IT_BDCMSGCOLL-MSGV3
      V4                   = IT_BDCMSGCOLL-MSGV4
    IMPORTING
      MSG                =  G_MSGTXT
    EXCEPTIONS
      NOT_FOUND          = 8.

*Accumulate messages 
  ...

ENDLOOP.

*Now you can pass accumulate G_MSGTXT to your RFC FM.
...

Regards,

Ferry Lianto

0 Kudos

Thanks for the reply Gurus....

I have to separate success,warning and error messages from one another so what i tried doing was this....

CALL TRANSACTION 'FV50L' USING t_bdcdata MESSAGES INTO

t_messages OPTIONS FROM options.

LOOP AT t_messages INTO wa_messages.

IF ( wa_messages-msgtyp = c_msg_suc_typ )

<< Now HERE what shud i do....

IF ( wa_messages-msgtyp = c_msg_err_typ OR wa_messages-msgtyp = c_msg_war_typ ).

MOVE:

c_msg_err_typ TO wa_result-result_flag,

c_msg_war_typ TO wa_result-result_flag.

CALL FUNCTION 'MESSAGE_TEXT_BUILD'

EXPORTING

MSGID = wa_messages-MSGID

MSGNR = wa_messages-MSGNR

MSGV1 = wa_messages-MSGV1

MSGV2 = wa_messages-MSGV2

MSGV3 = wa_messages-MSGV3

MSGV4 = wa_messages-MSGV4

IMPORTING

MESSAGE_TEXT_OUTPUT = wa_result-message.

APPEND wa_result TO tb_result.

ENDIF.

CLEAR: wa_result.

ENDLOOP.

Thanks for the help....

Sam

Message was edited by:

Sam williams

0 Kudos

I think you're making a mistake.

To make the FM flexible, you should just return the messages and a return code. This is how BAPIs work. It's up to the calling program to figure out what to do with the messages.

Rob

0 Kudos

Thanks for the reply Rob...

Then how shud i change the code so that it just returns the message and the return code...

Actually the calling program is in the DI layer i mean it is being called from a non sap system...thats the reason i am trying to send exact mesages to it back...

Please suggest...

Sam

0 Kudos

Well, It's up to you how you're going to handle it. But as I said in my original post, you can just return the original message table in the tables parameter (and the return code in an exporting parameter).

Then if the requirements for handling the messages change at a later date, you just change the calling program.

Rob