‎2007 Feb 23 2:12 PM
hi guys,
i am getting a data in XML format which consists of all purchase orders and there is a standard program available which converts this XML data to IDOC but before posting this IDOC in SAP database, i need to validate data in IDOC with SAP data if error the i need to display content in error idoc to screen.
i.e XML files have purchase order no's so this PO's should be validated with PO's in SAP if matches or exist then update details of PO in to SAP using IDOC or else display error idocs or error message to screen.
can any one please help me how do we do this, if possible with a piece of code.
thank you
pavan
‎2007 Feb 23 5:52 PM
hi,
i will just elaborate it. This XML files consists of Po's and materials from all vendors and these PO's and materials are already existing one in SAP so, there is an inbound program which converts this XML data in to IDOC. Now my job to validate data in IDOC before posting it to Ztable. and i hope it should create one idoc for every PO no in XML file.
so can you please tell me how to unpack the idoc and validate the data in idoc before posting it to Ztable. ex: Purchase order is in Idoc - so before posting this PO in to Ztable how should i validate whether this PO there in Ztable or not so if there only then i need to post details of it to ztable.
because we need to track the PO's coming from vendor are existing are not in our SAP database and generate an Error report.
i hope u understood me plss guide me regarding this and please get back to me if u still have any queries.
thank you
pavan
‎2007 Feb 23 4:46 PM
Pavan , what is the name of his program you are talking about.
Also do you mean the X12 file has lot of PO numbers and you need to csreen them first?
Another thing is if the X12 data has PO #'s and they are existing PO numbers then are these PO changes? the Idoc which will post.
Please give more details
‎2007 Feb 23 5:52 PM
hi,
i will just elaborate it. This XML files consists of Po's and materials from all vendors and these PO's and materials are already existing one in SAP so, there is an inbound program which converts this XML data in to IDOC. Now my job to validate data in IDOC before posting it to Ztable. and i hope it should create one idoc for every PO no in XML file.
so can you please tell me how to unpack the idoc and validate the data in idoc before posting it to Ztable. ex: Purchase order is in Idoc - so before posting this PO in to Ztable how should i validate whether this PO there in Ztable or not so if there only then i need to post details of it to ztable.
because we need to track the PO's coming from vendor are existing are not in our SAP database and generate an Error report.
i hope u understood me plss guide me regarding this and please get back to me if u still have any queries.
thank you
pavan
‎2007 Feb 23 6:14 PM
ok before I tell you anything, if you have a mapping software which maps XML file to an Idoc , then that is where you first check for duplicates, and send back to the sender.
But about your query, since you append to a ZTABLE , then you must have some custom code written.
So take all the PO's and select from Ztable where PO = POin xml file.
If you get a hit , thats a duplicate so put it in an internal table , if yuo do not get a hit, thats a new PO .
So append tat to your Ztable. there are many ways you can write the code.
Regarding unpacking the idoc. you need to say for example,
if idoc-segnam = segment , move idoc-sdata to zsegment
where zsegment has been defined like the idoc segment.
The sdata field has the data in the Idoc.
so for example when you move the segment containing PO number to the zsegment , there you can validate the PO number from Zsegment.
But again, finding a duplaicte should be done by the mapping system. it the most efficient way.
Regards
‎2007 Feb 23 6:30 PM
hi,
actually vendor stores their XML file in a path and when a file is stored there then a batch program runs and converts it in to IDOC so i just have to unpack this idoc and validate the data in it with SAP data and just display the error report thats all.
i know that sdata field consists of actual data of idoc and need to check the message type to know the segment details but could not understand how to unpack the idoc and check for validations.
is that possible for you to help me with a piece of code.
thank you
pavan
‎2007 Feb 23 6:41 PM
It seems that your Idoc is getting created and then you want to validate the PO's.
So your Idoc unpacking is being done there in that program which creates the Idoc.
now all you want to do is check for duplicates against table ztable right?
So now whereever you append the PO from the idoc to Ztable, there just before doing that check for the PO number against the Ztable entries.
Below is just some rough example. there are better/efficient ways to write this , so use this just as a guide.
loop at itab.
Select single EBELN from Ztable
where EBELN = Itab-ebeln.
If sy-subrc = 0. ( Po is present , then error)
move itab-ebeln to itab_z_err_po-ebeln.
append z_err_po.
else. ( not found)
move itab to ztable
append ztable.endif.
endloop.
‎2007 Feb 23 7:04 PM
hi sandeep,
Actually unpacking is not done in this program, as you see the scenario where outbound program exists which only creates the idoc using master_idoc_distribute with required data, the same thing this program in our requirement does which only creates idoc with required data.
so my job is to unpack and validate it with SAP data since i never worked on creating inbound function module i was just confused of how to unpack and validate
it.
any way thanks for your answers, if possible try to answer how to unpack.
pts will be awarded.
thank you
pavan