Industry Scenario–> Manage the data in different formats! ! Part-1
This is one of the real life implementation scenarios where the data was to come in the XML format, needed to be posted as a IDoc and then after some postings in the SAP, it was required to be converted into the Baan format text file which had some fields in pipe delimited format.Sounds Interesting!
The process had to be totally automated and three parties involved were customer who was sending the data in XML format , SAP (running on WAS 6.2) system which was receiving it and carrying out business transactions and Vendor who was getting the Baan format file.
Now, the data which was coming in the XML format from customer was the PO information which was required to be posted as a Sales Order, subsequently creating a purchase order in SAP system and then sending it to the vendor in the text file BAAN format. Further it was required that a order acknowledgement file coming from the vendor in the BAAN format, was required to be posted as order response in SAP system, further sending the same file in the XML format to the customer.
In this weblog, I would explain the first scenario where the orders were sent to the vendor, order acknowledgement portion would be taken in the next weblog.
Plunge into the waters,the swimming automatically comes!! That’s what happened!
XML format for posting the orders: This XML format was created by using the third party tool where we downloaded the XML schema for the “ORDERS05” IDoc type (Transaction WE60). Generated the XML file and removed the non-mandatory, non-required fields which was not required.
Create a service (Transaction: SICF) to create the link where the XML was being posted. The service had a class handler CL_HTTP_IDOC_XML_REQUEST. This SAP standard handler which passes the IDoc to ALE layer and sends a response back to the sender of the HTTP request “IDoc-XML-inbound ok” ,If the IDoc was created .
Otherwise, in case of any other error , it was HTTP 408/409 error. Here we did some customization, as our user wanted the XML error to be returned. We copied the standard handler to a “Z” and in the IF_HTTP_EXTENSION interface of the handler, wherever 408/409 error was returned changed it to the customized XML message. Do not forget to give the background user in the service!!
The process was required to be automatic, trigger to create a sales order and then purchase order in the SAP system.
In the partner profile configuration, for the inbound orders message, normally the process code for standard sales order creation is “ORDE” for creating the sales order.
But here we needed to trigger the creation of the purchase order as well in SAP , and also at the same time creating the BAAN text file to be sent across to the vendor.
1. Create a custom ‘Z’ function module (interface is the same as that of standard) , which calls the standard ‘IDOC_INPUT_ORDERS’ to create the Sales order and also the BAPI_PO_CREATE to create the purchase order (values required to create the PO taken in from the IDoc posted).
In the same function module a logic could be written to create the BAAN pipe delimited text file.This logic is the ABAP code which creates the pipe delimited BAAN text file.
2. Assign the function module in ALE attributes using the transaction BD51.
3. Assign the function module to the message type and the application object using transaction WE57.
4. Create the inbound process code and attach this function module to this process code using transaction WE42 , the parameters being the same as that of the standard “ORDE”.
5. The file created for the vendor was stored on the application server .As external FTP was not allowed from the application server, a separate servlet code was written to run on the server in DMZ zone , which would run the thread, to check if any file was formed on application server and as soon as it was, the file was read by that program and sent to the vendor’s FTP address.
The snippet of the code for the ‘Z’ function module is :