2008 Jul 21 7:12 AM
Hi all
I have done a module pool which calls the standard transaction 'MB1B' using the bdcdata.
The Transaction 'MB1B' returns a doc number in message
saying 'Docno posted successfully'.
Based on that number only i have to continue my module pool.
Can anyone say how to get that doc number through bdc in module pool
Cheers
Christina
2008 Jul 21 7:15 AM
hi,
instead use bapi for that........here i am providing sample code
here in this under importing you will receive the document number posted......
REPORT ZRPT_SUB_KO01GOODSMOVEMENT.
PARAMETERS : P_BAG(17) TYPE C,
P_ZZORG LIKE zaUFK-ZZORG,
P_MATNR LIKE MARA-MATNR,
P_WERKS LIKE AUFK-WERKS,
P_WERK LIKE AFPO-PWERK,
P_DATE LIKE MKPF-BUDAT,
P_LGORT LIKE GOITEM-LGOBE.
DATA : BDC_DATA TYPE STANDARD TABLE OF BDCDATA. "internla table for bdc data
DATA : WA_BDC_DATA TYPE BDCDATA . "work area for bdc data
DATA : T_XMSEG TYPE MSEG.
DATA : T_XMKPF TYPE MKPF.
DATA : V_BAGS1(17) TYPE C.
DATA : BEGIN OF WA_MB1B,
ZZGCODE TYPE ZMIGO-ZZGCODE,
ZZGBAGS TYPE ZMIGO-ZZGBAGS,
WERKS TYPE AUFK-WERKS,
LGORT TYPE VBRP-LGORT,
ZZORG TYPE zAUFK-ZZORG,
END OF WA_MB1B.
DATA : V_MATERIAL TYPE BAPI2017_GM_HEAD_RET-MAT_DOC.
data : v_date(10) type c.
DATA : T_GOODSMVT_HEADER TYPE BAPI2017_GM_HEAD_01,
T_GOODSMVT_CODE TYPE BAPI2017_GM_CODE,
T_GOODSMVT_ITEM TYPE STANDARD TABLE OF BAPI2017_GM_ITEM_CREATE,
T_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
DATA : WA_GOODSMVT_ITEM TYPE BAPI2017_GM_ITEM_CREATE.
DATA : BEGIN OF S_MARA,
MEINS LIKE MARA-MEINS,
END OF S_MARA.
DATA : MATERIALDOCUMENT TYPE BAPI2017_GM_HEAD_RET-MAT_DOC.
*FORM GOODSMOVEMENT TABLES T_RETURN
USING WA_MB1B LIKE WA_MB1B.
SELECT SINGLE MEINS
FROM MARA
INTO S_MARA
WHERE MATNR = P_MATNR.
CONCATENATE p_date6(2) p_date4(2) p_date+0(4) INTO V_DATE SEPARATED BY '.'.
T_GOODSMVT_HEADER-PSTNG_DATE = P_DATE.
T_GOODSMVT_HEADER-DOC_DATE = P_DATE.
T_GOODSMVT_CODE-GM_CODE = '04'.
WA_GOODSMVT_ITEM-MATERIAL = P_MATNR. "'000000000000001556'.
WA_GOODSMVT_ITEM-PLANT = P_WERK. " '1000'.
WA_GOODSMVT_ITEM-STGE_LOC = P_LGORT. " '0001'.
WA_GOODSMVT_ITEM-MOVE_TYPE = 'Z42'.
WA_GOODSMVT_ITEM-VENDOR = P_ZZORG. "'0000100224'.
WA_GOODSMVT_ITEM-ENTRY_QNT = P_BAG. " '1'.
WA_GOODSMVT_ITEM-ENTRY_UOM = S_MARA-MEINS.
WA_GOODSMVT_ITEM-ENTRY_UOM_ISO = S_MARA-MEINS.
WA_GOODSMVT_ITEM-MOVE_PLANT = P_WERKS.
APPEND WA_GOODSMVT_ITEM TO T_GOODSMVT_ITEM.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = T_GOODSMVT_HEADER
GOODSMVT_CODE = T_GOODSMVT_CODE
IMPORTING
MATERIALDOCUMENT = V_MATERIAL
TABLES
GOODSMVT_ITEM = T_GOODSMVT_ITEM
RETURN = T_RETURN.
BREAK shailajaa.
EXPORT t_return to MEMORY ID '123'.
EXPORT V_MATERIAL TO MEMORY ID 'MAT'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = ' '.
*ENDFORM.
2008 Jul 21 7:15 AM
hi,
instead use bapi for that........here i am providing sample code
here in this under importing you will receive the document number posted......
REPORT ZRPT_SUB_KO01GOODSMOVEMENT.
PARAMETERS : P_BAG(17) TYPE C,
P_ZZORG LIKE zaUFK-ZZORG,
P_MATNR LIKE MARA-MATNR,
P_WERKS LIKE AUFK-WERKS,
P_WERK LIKE AFPO-PWERK,
P_DATE LIKE MKPF-BUDAT,
P_LGORT LIKE GOITEM-LGOBE.
DATA : BDC_DATA TYPE STANDARD TABLE OF BDCDATA. "internla table for bdc data
DATA : WA_BDC_DATA TYPE BDCDATA . "work area for bdc data
DATA : T_XMSEG TYPE MSEG.
DATA : T_XMKPF TYPE MKPF.
DATA : V_BAGS1(17) TYPE C.
DATA : BEGIN OF WA_MB1B,
ZZGCODE TYPE ZMIGO-ZZGCODE,
ZZGBAGS TYPE ZMIGO-ZZGBAGS,
WERKS TYPE AUFK-WERKS,
LGORT TYPE VBRP-LGORT,
ZZORG TYPE zAUFK-ZZORG,
END OF WA_MB1B.
DATA : V_MATERIAL TYPE BAPI2017_GM_HEAD_RET-MAT_DOC.
data : v_date(10) type c.
DATA : T_GOODSMVT_HEADER TYPE BAPI2017_GM_HEAD_01,
T_GOODSMVT_CODE TYPE BAPI2017_GM_CODE,
T_GOODSMVT_ITEM TYPE STANDARD TABLE OF BAPI2017_GM_ITEM_CREATE,
T_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
DATA : WA_GOODSMVT_ITEM TYPE BAPI2017_GM_ITEM_CREATE.
DATA : BEGIN OF S_MARA,
MEINS LIKE MARA-MEINS,
END OF S_MARA.
DATA : MATERIALDOCUMENT TYPE BAPI2017_GM_HEAD_RET-MAT_DOC.
*FORM GOODSMOVEMENT TABLES T_RETURN
USING WA_MB1B LIKE WA_MB1B.
SELECT SINGLE MEINS
FROM MARA
INTO S_MARA
WHERE MATNR = P_MATNR.
CONCATENATE p_date6(2) p_date4(2) p_date+0(4) INTO V_DATE SEPARATED BY '.'.
T_GOODSMVT_HEADER-PSTNG_DATE = P_DATE.
T_GOODSMVT_HEADER-DOC_DATE = P_DATE.
T_GOODSMVT_CODE-GM_CODE = '04'.
WA_GOODSMVT_ITEM-MATERIAL = P_MATNR. "'000000000000001556'.
WA_GOODSMVT_ITEM-PLANT = P_WERK. " '1000'.
WA_GOODSMVT_ITEM-STGE_LOC = P_LGORT. " '0001'.
WA_GOODSMVT_ITEM-MOVE_TYPE = 'Z42'.
WA_GOODSMVT_ITEM-VENDOR = P_ZZORG. "'0000100224'.
WA_GOODSMVT_ITEM-ENTRY_QNT = P_BAG. " '1'.
WA_GOODSMVT_ITEM-ENTRY_UOM = S_MARA-MEINS.
WA_GOODSMVT_ITEM-ENTRY_UOM_ISO = S_MARA-MEINS.
WA_GOODSMVT_ITEM-MOVE_PLANT = P_WERKS.
APPEND WA_GOODSMVT_ITEM TO T_GOODSMVT_ITEM.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = T_GOODSMVT_HEADER
GOODSMVT_CODE = T_GOODSMVT_CODE
IMPORTING
MATERIALDOCUMENT = V_MATERIAL
TABLES
GOODSMVT_ITEM = T_GOODSMVT_ITEM
RETURN = T_RETURN.
BREAK shailajaa.
EXPORT t_return to MEMORY ID '123'.
EXPORT V_MATERIAL TO MEMORY ID 'MAT'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = ' '.
*ENDFORM.
2008 Jul 21 8:28 AM
Hi
I have the BAPI 'BAPI_GOODSMVT_CREATE'.
But it is giving me an error 'Enter Purchase Order;..
But for my transaction MB1B, PO is not necessary.
Can u pls help
Cheers
Christina
2008 Jul 21 7:15 AM
Hi,
You can get the Doc Number form the message variable.
Hope this helps.
2008 Jul 21 7:19 AM
call transaction p_tcode using bdcdata mode p_mode
update p_update messages into xmessages.
clear lin.
describe table xmessages lines lin.
if lin > 0.
loop at xmessages.
if xmessages-msgtyp = 'E' or
xmessages-msgtyp = 'S'.
move-corresponding xmessages to: bdcerror,msg_log.
msg_log-msgno = xmessages-msgnr.
msg_log-msgty = xmessages-msgtyp.
call function 'MESSAGE_TEXTS_READ'
exporting
msg_log_imp = msg_log
importing
msg_text_exp = msg_text
exceptions
others = 1.
bdcerror-msgtx = msg_text-msgtx.
append bdcerror.
endif.
bdcerror this internal table hold all the message...............
this will help u
Regards
Anbu
Edited by: Anbu B on Jul 21, 2008 8:19 AM
2008 Jul 21 7:19 AM
Hi ,
After that u can display that Document in another Screen with double click option ,when they double click that document number -->take them to MB03 with Mat Document.
or get data from MKPF+MSEG based on the Document + Year
Regards
Prabhu
2008 Jul 21 7:21 AM
hi,
try this exits,
MBCF0002 Customer function exit: Segment text in material doc. item
MBCF0005 Material document item for goods receipt/issue slip
MBCF0007 Customer function exit: Updating a reservation
MB_CF001 Customer Function Exit in the Case of Updating a Mat. Doc.
regards,
sandeep