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

About Two BAPI

Former Member
0 Likes
1,548

hi,all

BALW_BAPIRETURN_GET, BALW_BAPIRETURN_GET2,how to use them. what case and which will be used.

Plz give me some sample and description.

thanks in advance.

Kevin

Some code. i don't it is right ?

&----


*& Form SET_RETURN_MESSAGE

&----


  • This routine is used for setting the BAPI return message.

  • The routine is a standard routine for BAPIs that handles the message

  • structure for the BAPIRETURN structure. It has been copied from the

  • BAPI Company Code Getlist

----


  • -->P_MESSAGE text

  • <--P_RETURN text

----


FORM set_return_message USING value(p_message) LIKE message

CHANGING p_return LIKE bapireturn.

CHECK NOT message IS INITIAL.

CALL FUNCTION 'BALW_BAPIRETURN_GET'

EXPORTING

type = p_message-msgty

cl = p_message-msgid

number = p_message-msgno

par1 = p_message-msgv1

par2 = p_message-msgv2

par3 = p_message-msgv3

par4 = p_message-msgv4

  • LOG_NO = ' '

  • LOG_MSG_NO = ' '

IMPORTING

bapireturn = p_return

EXCEPTIONS

OTHERS = 1.

ENDFORM. " SET_RETURN_MESSAGE

&----


*& Form SET_RETURN_MESSAGETABLE

&----


----


  • -->P_MESSAGETABLE text

  • <--P_RETURN text

----


FORM set_return_messaGetable

USING

value(p_message) LIKE messagetable

CHANGING

prs_return LIKE bapiret2.

CHECK NOT message IS INITIAL.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

type = p_message-mstty

cl = p_message-mstid

number = p_message-mstno

par1 = p_message-mstv1

par2 = p_message-mstv2

par3 = p_message-mstv3

par4 = p_message-mstv4

LOG_NO = p_message-log_no

LOG_MSG_NO = p_message-log_msg_no

parameter = p_message-parameter

row = p_message-row

field = p_message-field

IMPORTING

bapiret2 = prs_return

EXCEPTIONS

OTHERS = 1.

ENDFORM. " SET_RETURN_MEGTABLE

6 REPLIES 6
Read only

nablan_umar
Product and Topic Expert
Product and Topic Expert
0 Likes
1,346

Hi Kevin,

If you are writing a new function module that you have a message returned back from this new function in a format of BAPIRETURN or BAPIRET2, then you can use those function modules to format your return message. Otherwise, I don't think you will need to use it at all.

Read only

0 Likes
1,346

YES, i have define an function module, one of parameter is

TABALES messagetable like bapiret2.

another is RETURN like BAPIRETURN.

like below

*"----


""Local interface:

*" IMPORTING

*" REFERENCE(ORDER_HEADER_IN) LIKE VBAK STRUCTURE VBAK

*" REFERENCE(CALENDER_ID) LIKE SCAL-FCALID

*" EXPORTING

*" REFERENCE(RETURN) LIKE BAPIRETURN STRUCTURE BAPIRETURN

*" TABLES

*" ORDER_ITEMS_TAB STRUCTURE VBAPVB

*" MESSAGETABLE STRUCTURE BAPIRET2

*"----


but, above is return struture ,nor internal table. right?

how to add all message to MESSAGETABLE, and the last message save into RETURN

Read only

nablan_umar
Product and Topic Expert
Product and Topic Expert
0 Likes
1,346

Kevin,

Looking at your codes, MESSAGETABLE is an internal table. You are doing it correctly. Now when you faced with any kind of messages in your function module, you can call those function modules to convert the message you have into the internal table MESSAGETABLE.

For example in your code, you call a function module that can return an exceptions

CALL FUNCTION 'ANY_FUNCTION'

EXPORTING

PARA1 = lv_para1

PARA2 = lv_para2

IMPORTING

PARA3 = lv_para3

PARA4 = lv_para4

EXCEPTIONS

ERROR1 = 1

ERROR2 = 2.

Then, you should consolidate the exceptions from this function module calls into your messagetable.

IF SY-SUBRC ne 0.

CLEAR MESSAGETABLE.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

TYPE = sy-msgty

CL = sy-msgid

NUMBER = sy-msgno

PAR1 = sy-msgv1

PAR2 = sy-msgv2

PAR3 = sy-msgv3

PAR4 = sy-msgv4

IMPORTING

RETURN = messagetable.

APPEND messagetable.

ENDIF.

You should do this for all function modules call, message statements and any kind of messages you want to return to the calling program.

Read only

0 Likes
1,346

Thanks for your help.

i got it.

Do you have MSN , Could you like chatting with me.

I am from SAP China.

thanks again,

Kevin,

Read only

nablan_umar
Product and Topic Expert
Product and Topic Expert
0 Likes
1,346

I don't have MSN. I have Yahoo but not at my current customer site. You can post your question here and I will answer as much as I can.

Read only

0 Likes
1,346

thank you very much

i will sleep.

My email : xiaoyao76320@163.com

Could you send me a mail ,using mailbox you use frequently.

thanks again,

Best Regards,

Kevin,