‎2006 Aug 18 3:57 AM
Hi there,
recently my company wants to use a 3rd party EDI software .but we will not use IDOC in SAP.we will use text file in place of IDOC.
the procedure is as follows.
( when receiving a EDI document from client)
1) our EDI software will capture the data when our client will send purchase order(EDI format) to our company.
2)then EDI will convert the EDI format PO to a text formatted file where all the data will be there.
3)so i need to write a uploading program to upload those PO datas from the text file to our SAP system.
4)is there anything to do after uploading those datas into SAP?plz suggest.
may be in my upload program, i have to put the transaction to create sales order after uploading the purchase order data.
(when our company will send the document to client)
1)when we r doing a purchase order or sales order by any transaction, there ,we have to put some trigger in user-exit so that my download program will be executed.
2)this download program is to download the SAP PO or SO data to a text file format.
3)then we will send this text file to that 3rd party EDI software.this software will convert the text file format to EDI format & then it will send that EDI doc to our client.
for this, i need
1)to create text file from EDI format.
how to know the text file format?
how to read & analyse the EDI format ?
2)i need the report to create PO or SO using BAPI?
once i uploaded the data to SAP,i can trigger to create PO or SO as per my requirement.i need these reports urgently. my mail id is pmr_sir@yahoo.co.in.plz send me to my mail id.
Thanks in advance.
Regards
pabitra
‎2006 Aug 18 5:41 AM
I have seen ur requirement in SDN. U dont need to panic. It is a normal thing only.
In inbound processing i.e when you receive an order from your customer ,
- EDI manager will convert the EDIFACT file into an IDoc file.
- Then we can create an IDoc from this file.
- Once you have the IDoc, then function module IDOC_INPUT_ORDERS will run and post the IDoc into SAP system. Then the tables relevant are updated. You dont need
to create any application document like Purchase order. It is taken care of by the function module.
In the same way, at the outbound processing also
- when you create an application document, function module IDOC_OUTPUT_ORDERS is made to run. This creates the IDoc. What happens next is just opposite.
So all you need to is a bit of configuration. You need to know some ALE customizing for this. Hope this helps you. Please write for further clarifications.
‎2006 Aug 18 5:41 AM
I have seen ur requirement in SDN. U dont need to panic. It is a normal thing only.
In inbound processing i.e when you receive an order from your customer ,
- EDI manager will convert the EDIFACT file into an IDoc file.
- Then we can create an IDoc from this file.
- Once you have the IDoc, then function module IDOC_INPUT_ORDERS will run and post the IDoc into SAP system. Then the tables relevant are updated. You dont need
to create any application document like Purchase order. It is taken care of by the function module.
In the same way, at the outbound processing also
- when you create an application document, function module IDOC_OUTPUT_ORDERS is made to run. This creates the IDoc. What happens next is just opposite.
So all you need to is a bit of configuration. You need to know some ALE customizing for this. Hope this helps you. Please write for further clarifications.
‎2006 Aug 18 12:49 PM
HI,
thanks for ur answer.but i have clearly mentioned that we <b>will not use IDOC</b>.we r using general text file(.txt).
when my company will get a edi document (let PO) from client, our edi software will convert that edi document to text file format. then i have to write a report to upload that text file to sap data base.
After uploading,we have to raise a sales order againest that purchase order.so i need to create the sales order.so for this ,i need to write a report in bapi which can create a sales order.
i have to write a report in bapi to create purchase order as well.
so i need the reports in bapi which can create PO or SO.
Thanks for ur help.
Regards
pabitra
‎2006 Aug 18 2:04 PM
Pabitra
Basically, you can do the needful via one abap which would upload the text file and create the SO using BAPI's
and once the order is created you can get the required information from the order and create a text file. Later the EDI mapping tool can pick the file and map it and sent it to the client.
U can populate the parameters and use the bapi
BAPI_SALESORDER_CREATEFROMDAT1 to create the sales order.
Message was edited by: Anurag Bankley
‎2006 Aug 19 9:03 AM
hi anurag,
Thanks very much for ur answer & i will award the points as well.
is there any function module in BAPI which will create a purchase order when i upload a text file.
i am new to bapi.can u plz give me the proper link where can i get the BAPI documents so that it will be easy for me to write those reports.
so ,in my report of SO,i will populate the data to this FM--BAPI_SALESORDER_CREATEFROMDAT1 .then Sales Order will be created.is there any other FM i have to use in my report with addition to this.
it is a great help for me if u can provide some sample code as i am new to bapi.
Thanks a lot
Regards
pabitra
‎2006 Aug 19 11:11 AM
U would need to commit the transaction at end of the document creation via another BAPI...I will send you the code on Monday ...similar to above there are many other bapi's available you can search for the same in SE37 with BAPI*
I hope thatz fine with you ?
Regards
Anurag
‎2006 Aug 22 4:07 AM
Hi anurag,
i need to write a report to create sales order using BAPI & also to create shipment order using BAPI.
plz forward me some sample codes in BAPI so that i can refer as i am very new to bapi.my mail id is pmr_sir@yahoo.co.in.
it is very urgent yar.
Thanks u very much.
Regards
pabitra
‎2006 Aug 22 12:05 PM
Sample code for BAPI ---
&----
*& Include ZG00L_VMI_ORDER_MAIN *
&----
at selection-screen.
*if not P_KUNNR is initial and not p_vmil is initial.
message e319(000) with 'Please Enter Either VMI Location or Customer'
space
space
space.
*
*elseif P_KUNNR is initial and p_vmil is initial.
message e319(000) with 'Please Enter VMI Location or Customer'
space
space
space.
*
*endif.
start-of-selection.
perform get_planned_orders.
Build fieldcatalog for the ALV
perform BUILD_FIELDCAT.
perform EVENTTAB_BUILD using IT_EVENTS
C_TOP_OF_PAGE
C_USER_COMMAND.
perform COMMENT_BUILD using IT_LIST_TOP_OF_PAGE.
perform SET_LAYOUT using IS_LAYOUT.
Display ALV
if IT_OUT[] IS INITIAL.
PERFORM exit_program.
ELSE.
perform DISPLAY_ALV.
ENDIF.
&----
*& Form get_planned_orders
&----
text
----
--> p1 text
<-- p2 text
----
FORM get_planned_orders .
select *
from ZLL_LO_VMI_VMX
into table it_vmi
where EXTDATE eq p_extd
and CUSTOMER eq p_kunnr
and vmilocn eq p_vmil.
select matnr
werks
labst
into table it_mard1
from mard
for all entries in it_vmi
where werks eq p_vmil
and matnr eq it_vmi-product.
if not it_mard1[] is initial.
loop at IT_MARD1 into IS_MARD.
collect IS_MARD into IT_MARD.
endloop.
endif.
clear IS_MARD.
*PALLET QTY
select matnr
MEINH
UMREZ
into table IT_MARM
from MARM
for all entries in it_vmi
where MATNR = it_vmi-product and
MEINH in ('E1','U1').
*LAYER QTY
select matnr
MEINH
UMREZ
into table IT_MARM1
from MARM
for all entries in it_vmi
where MATNR = it_vmi-product and
MEINH in ('EL','UL').
*ABC Indicator
if not it_vmi[] is initial.
loop at it_vmi into is_vmi.
*Product
is_out-PRODUCT = is_vmi-PRODUCT.
*safety stock
is_out-SSTK = is_vmi-sstk.
*Confirmed Qty
is_out-CONFQTY = is_vmi-confqty.
*Recommanded Qty
is_out-RECQTY = is_vmi-recqty.
*Product Description.
select single maktx
into makt-maktx
from makt
where matnr eq is_vmi-product.
if sy-subrc eq 0.
is_out-maktx = makt-maktx.
endif.
*ABC Indicator,Stock In Transit
if not is_vmi-VMILOCN is initial.
select single *
from marc
where matnr eq is_vmi-product
and werks eq is_vmi-VMILOCN.
if sy-subrc eq 0.
is_out-maabc = marc-maabc.
is_out-TRAME = marc-trame.
endif.
endif.
*Available Valuated Stock
if not it_mard[] is initial.
read table it_mard into is_mard
with key matnr = is_vmi-product
werks = is_vmi-vmilocn.
if sy-subrc eq 0.
is_out-labst = is_mard-labst.
endif.
endif.
append is_out to it_out.
endloop.
endif.
ENDFORM. " get_planned_orders
&----
*& Form TOP_OF_PAGE
&----
text
----
--> p1 text
<-- p2 text
----
FORM TOP_OF_PAGE .
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
I_LOGO = ' '
IT_LIST_COMMENTARY = IT_LIST_TOP_OF_PAGE.
ENDFORM. " TOP_OF_PAGE
&----
*& Form USER_COMMAND
&----
text
----
--> p1 text
<-- p2 text
----
FORM USER_COMMAND using R_UCOMM type SY-UCOMM
RS_SELFIELD type SLIS_SELFIELD.
*/----
The Details of each product and change in Confirmed qty
will be saved and back to ALV report for creating a sales order
and post order Confrimation EDI.
*/----
case r_ucomm.
WHEN '&ETA1'. "Details
clear l_count.
LOOP AT IT_OUT INTO IS_OUT WHERE BOX = 'X'.
L_COUNT = L_COUNT + 1.
ENDLOOP.
IF L_COUNT > 1.
message e319(000) with 'Select One Line Product Only'
space
space
space.
ENDIF.
read table IT_out into IS_out index RS_SELFIELD-TABINDEX.
if SY-SUBRC eq 0.
*Extend date
ZLL_LO_VMI_VMX-EXTDATE = p_extd. "Extend Date
*If Customer and date is given then find out VMI Location
if not p_kunnr is initial and not P_EXTD is initial.
clear is_vmi.
KNA1-KUNNR = p_kunnr. "Customer
read table it_vmi into is_vmi with key
EXTDATE = P_EXTD
CUSTOMER = p_kunnr.
if SY-SUBRC eq 0.
ZLL_LO_VMI_VMX-VMILOCN = is_vmi-VMILOCN. "VMI Location
endif.
*Else find out Customer
elseif not p_vmil is initial and not P_EXTD is initial.
clear is_vmi.
read table it_vmi into is_vmi with key
EXTDATE = P_EXTD
CUSTOMER = p_vmil.
if SY-SUBRC eq 0.
ZLL_LO_VMI_VMX-customer = is_vmi-CUSTOMER. "Customer
endif.
ZLL_LO_VMI_VMX-VMILOCN = p_vmil.
endif.
*Product & Description
ZLL_LO_VMI_VMX-PRODUCT = is_out-PRODUCT. "Product
MAKT-MAKTX = is_out-maktx. "Material Description
*Safety Stock
ZLL_LO_VMI_VMX-SSTK = is_out-sstk. "Safety Stock
*Confirmed Qty
ZLL_LO_VMI_VMX-CONFQTY = is_out-confqty. "Confirmed Qty
*Required Qty
ZLL_LO_VMI_VMX-RECQTY = is_out-recqty. "Required Qty
*SAP Available Stock
MARD-LABST = is_out-labst. "SAP Available Stock
*ABC Indicator
MARC-MAABC = is_out-maabc. "ABC Indicator
*Stock In Transit
MARC-TRAME = is_out-trame. "Stock In Transit
*EAN Number
select single ean11
into mara-ean11
from mara
where matnr eq is_out-product.
*Fiscal Week
*Min Shipping qty
*Inc.Shipping Qty
*Unit Price
*Customer Product Code
*UK/EU Pallet Qty
clear is_marm.
read table it_marm into is_marm
with key
matnr = is_out-product
meinh = 'E1'.
if sy-subrc eq 0.
UMREZ1 = is_marm-umrez.
endif.
clear is_marm.
read table it_marm into is_marm
with key
matnr = is_out-product
meinh = 'U1'.
if sy-subrc eq 0.
UMREZ2 = is_marm-umrez.
endif.
*UK/EU Layer Qty
clear is_marm.
read table it_marm1 into is_marm
with key
matnr = is_out-product
meinh = 'EL'.
if sy-subrc eq 0.
UMREZ3 = is_marm-umrez.
endif.
clear is_marm.
read table it_marm1 into is_marm
with key
matnr = is_out-product
meinh = 'UL'.
if sy-subrc eq 0.
UMREZ4 = is_marm-umrez.
endif.
*Caton/BOX Qty
select single SCMNG
into MVKE-SCMNG
from MVKE
where MATNR = is_out-product.
endif.
call screen 100.
when '&SAV'.
*Create sales order by calling Sales Order BAPI.
*Header
xheader-doc_type = 'TA'.
xheader-sales_org = 'LFR1'.
xheader-distr_chan = '10'.
xheader-division = '20'.
xheader-req_date_h = '20050616'.
xheader-purch_no_c = 'Test BAPI order'.
xheader-purch_date = '20050601'.
xheader-po_method = 'CWC'. "Constant
*Customer
if not p_vmil is initial and not P_EXTD is initial.
clear is_vmi.
read table it_vmi into is_vmi with key
EXTDATE = P_EXTD
CUSTOMER = p_vmil.
if SY-SUBRC eq 0.
ZLL_LO_VMI_VMX-customer = is_vmi-CUSTOMER. "customer
endif.
endif.
tpartners-partn_role = 'AG'.
*tpartners-partn_numb = '0000000011'.
tpartners-partn_numb = ZLL_LO_VMI_VMX-customer.
append tpartners.
*Ship-to-party
tpartners-partn_role = 'WE'.
*tpartners-partn_numb = '0000000011'.
tpartners-partn_numb = ZLL_LO_VMI_VMX-customer.
append tpartners.
clear is_out.
loop at it_out into is_out.
*Items
itm_num = itm_num + 1.
titems-itm_number = itm_num.
titems-material = is_out-PRODUCT.
titems-target_qty = is_out-CONFQTY.
append titems.
*Schedule lines for each item
tsched-itm_number = itm_num.
tsched-req_date = sy-datum.
tsched-req_qty = is_out-CONFQTY.
append tsched.
endloop.
clear : itm_num,is_out,sorder.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN = xheader
IMPORTING
SALESDOCUMENT = sorder
TABLES
RETURN = treturn
ORDER_ITEMS_IN = titems
ORDER_PARTNERS = tpartners
ORDER_SCHEDULES_IN = tsched.
if not ( sorder is initial ).
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
write: /'Order number:', sorder.
else.
write: /'Error'.
endif.
loop at treturn.
write: /'', treturn-id, treturn-number, treturn-message(80).
endloop.
endcase.
ENDFORM. " USER_COMMAND
&----
*& Form BUILD_FIELDCAT
&----
text
----
--> p1 text
<-- p2 text
----
FORM BUILD_FIELDCAT .
*PRODUCT
perform FILL_FIELDCAT using 'PRODUCT'
'IT_OUT'
''
''
TEXT-008
IS_FLDCAT
''
changing IT_FLDCAT.
*Description
perform FILL_FIELDCAT using 'MAKTX'
'IT_OUT'
''
''
TEXT-009
IS_FLDCAT
''
changing IT_FLDCAT.
*ABC Indicator
perform FILL_FIELDCAT using 'MAABC'
'IT_OUT'
''
''
TEXT-010
IS_FLDCAT
''
changing IT_FLDCAT.
*Intransit Stock
perform FILL_FIELDCAT using 'TRAME'
'IT_OUT'
'MEINS'
'MARA'
TEXT-014
IS_FLDCAT
''
changing IT_FLDCAT.
*Tol.Avl.Stock
perform FILL_FIELDCAT using 'LABST'
'IT_OUT'
'MEINS'
'MARA'
TEXT-012
IS_FLDCAT
''
changing IT_FLDCAT.
*Safety Stock
perform FILL_FIELDCAT using 'SSTK'
'IT_OUT'
''
''
TEXT-015
IS_FLDCAT
''
changing IT_FLDCAT.
*Confirmed qty
perform FILL_FIELDCAT using 'CONFQTY'
'IT_OUT'
''
''
TEXT-016
IS_FLDCAT
''
changing IT_FLDCAT.
*Recommended Qty
perform FILL_FIELDCAT using 'RECQTY'
'IT_OUT'
''
''
TEXT-017
IS_FLDCAT
''
changing IT_FLDCAT.
ENDFORM. " BUILD_FIELDCAT
&----
*& Form EVENTTAB_BUILD
&----
text
----
-->P_IT_EVENTS text
-->P_C_TOP_OF_PAGE text
-->P_C_USER_COMMAND text
----
FORM EVENTTAB_BUILD USING LT_EVENTS type SLIS_T_EVENT
TOP_PAGE type SLIS_FORMNAME
USER_COMMAND type SLIS_FORMNAME.
data: LS_EVENT type SLIS_ALV_EVENT.
call function 'REUSE_ALV_EVENTS_GET'
exporting
I_LIST_TYPE = 0
importing
ET_EVENTS = LT_EVENTS.
read table LT_EVENTS with key NAME = SLIS_EV_TOP_OF_PAGE
into LS_EVENT.
if SY-SUBRC = 0.
move TOP_PAGE to LS_EVENT-FORM.
modify LT_EVENTS from LS_EVENT transporting FORM
where NAME = SLIS_EV_TOP_OF_PAGE.
clear LS_EVENT.
endif.
read table LT_EVENTS with key NAME = SLIS_EV_USER_COMMAND
into LS_EVENT.
if SY-SUBRC = 0.
move USER_COMMAND to LS_EVENT-FORM.
modify LT_EVENTS from LS_EVENT transporting FORM
where NAME = SLIS_EV_USER_COMMAND.
clear LS_EVENT.
endif.
ENDFORM. " EVENTTAB_BUILD
&----
*& Form COMMENT_BUILD
&----
text
----
-->P_IT_LIST_TOP_OF_PAGE text
----
FORM COMMENT_BUILD using IT_TOP_OF_PAGE type SLIS_T_LISTHEADER.
data: LS_LINE type SLIS_LISTHEADER.
clear LS_LINE.
LS_LINE-TYP = 'H'.
LS_LINE-INFO = TEXT-001.
append LS_LINE to IT_TOP_OF_PAGE.
clear LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = TEXT-002.
LS_LINE-INFO = p_VMIL.
append LS_LINE to IT_TOP_OF_PAGE.
clear LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = TEXT-003.
LS_LINE-INFO = p_KUNNR.
append LS_LINE to IT_TOP_OF_PAGE.
clear LS_LINE.
select single name1
into kna1-name1
from kna1
where kunnr eq p_kunnr.
if sy-subrc eq 0.
LS_LINE-INFO = kna1-name1.
endif.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = TEXT-004.
append LS_LINE to IT_TOP_OF_PAGE.
clear LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = TEXT-005.
LS_LINE-INFO = P_EXTD.
append LS_LINE to IT_TOP_OF_PAGE.
clear LS_LINE.
*Customer Requested Date
LS_LINE-TYP = 'S'.
LS_LINE-KEY = TEXT-006.
LS_LINE-INFO = P_MATNR.
append LS_LINE to IT_TOP_OF_PAGE.
clear LS_LINE.
*Purchase Order
LS_LINE-TYP = 'S'.
LS_LINE-KEY = TEXT-007.
LS_LINE-INFO = P_MATNR.
append LS_LINE to IT_TOP_OF_PAGE.
clear LS_LINE.
ENDFORM. " COMMENT_BUILD
&----
*& Form SET_LAYOUT
&----
text
----
-->P_IS_LAYOUT text
----
FORM SET_LAYOUT using PS_LAYOUT type SLIS_LAYOUT_ALV.
PS_LAYOUT-ZEBRA = C_X.
PS_LAYOUT-COLWIDTH_OPTIMIZE = C_X.
PS_LAYOUT-BOX_TABNAME = 'IT_OUT'.
PS_LAYOUT-BOX_FIELDNAME = 'BOX'.
ENDFORM. " SET_LAYOUT
&----
*& Form exit_program
&----
text
----
--> p1 text
<-- p2 text
----
FORM exit_program .
message I107(00).
exit.
ENDFORM. " exit_program
&----
*& Form DISPLAY_ALV
&----
text
----
--> p1 text
<-- p2 text
----
FORM DISPLAY_ALV .
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
IS_LAYOUT = IS_LAYOUT
IT_FIELDCAT = IT_FLDCAT
I_SAVE = C_SAVE
IT_EVENTS = IT_EVENTS
tables
T_OUTTAB = IT_OUT
exceptions
PROGRAM_ERROR = 1
others = 2.
if SY-SUBRC <> 0.
message id SY-MSGID type SY-MSGTY number SY-MSGNO
with SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
ENDFORM. " DISPLAY_ALV
&----
*& Form FILL_FIELDCAT
&----
text
----
-->P_0114 text
-->P_0115 text
-->P_0116 text
-->P_0117 text
-->P_TEXT_003 text
-->P_IS_FLDCAT text
-->P_0120 text
<--P_IT_FLDCAT text
----
FORM FILL_FIELDCAT using VALUE(P_FIELDNAME) type SLIS_FIELDNAME
VALUE(P_TABNAME) type SLIS_TABNAME
VALUE(P_REF_FIELDNAME) type DD03P-FIELDNAME
VALUE(P_REF_TABNAME) type DD03P-TABNAME
VALUE(P_TEXT) type TEXT132
VALUE(P_FIELDCAT) type SLIS_FIELDCAT_ALV
VALUE(P_HOTSPOT) type C
changing P_IT_FIELDCAT type SLIS_T_FIELDCAT_ALV.
P_FIELDCAT-FIELDNAME = P_FIELDNAME.
P_FIELDCAT-TABNAME = P_TABNAME.
P_FIELDCAT-REF_FIELDNAME = P_REF_FIELDNAME.
P_FIELDCAT-REF_TABNAME = P_REF_TABNAME.
P_FIELDCAT-DDICTXT = C_L.
P_FIELDCAT-SELTEXT_L = P_TEXT.
P_FIELDCAT-HOTSPOT = P_HOTSPOT.
P_FIELDCAT-NO_ZERO = 'X'.
append P_FIELDCAT to P_IT_FIELDCAT.
clear : P_FIELDCAT.
ENDFORM. " FILL_FIELDCAT
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'CHANGE'.
SET TITLEBAR '100'.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
MODULE USER_COMMAND_0100 INPUT.
case sy-ucomm.
when 'SAVE'.
when 'EXIT' or 'CANC' or 'BACK'.
leave to list-processing.
endcase.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Form SET_PF_STATUS
&----
text
----
--> p1 text
<-- p2 text
----
FORM SET_PF_STATUS using RT_EXTAB type SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD'.
ENDFORM. " SET_PF_STATUS