Business Connector Integrator IDOC/XML inbound mapping

Question: Hi,

we have SAP 4.0 with SAP Business Connector (BC) Integrator (4.0.1); with the BC Integrator we do some mappings for incoming IDOCs.

Sample IDOC available; Keys (or segments) in the IDOC are ORDRSP derived from ORDERS01, one of them E1EDP20, which should contain a field EDATU; unfortunately some incoming IDOCs have this field set to a valid date, some to a "virtual" date (e.g. 20991231), some are empty "", and some IDOCs have no EDATU field at all.

Below code to do the mapping can deal with the first three cases:
valid EDATU: no action
virtual EDATU ("20991231"): remove segment
empty EDATU (""): remove segment
missing EDATU: throws an exception, which it should not

So far we have recycled sample code, not a lot of experience.
I have tried to play with "findField" and "findSegment" but they do not work as referenced in IDOC_ClassLib.pdf (or help.sap.com)

I would like to ask you for:
a really good programmers guide for BC Integrator, if that exists
some advice what I am doing wrong
whether there is a solution to that problem at all
and / or what is the easiest / standard way to deal with such fields
(maybe "flows" are a better tool for this?)

Thank you for your patience and your help
matt

-------------------------------------------------------------------------
IDOCSegment segment1 = null;
IDOCSegment segment2 = null;
IDOCSegment segment3 = null;

try
{
/* changing two fields, this works fine */
IDOC idoc = new IDOC(in);
IDOCControl control = idoc.getControlRecord();
if (sender!=null)
{
control.setField(IDOCControl.SNDPRN, sender);
control.setField(IDOCControl.SNDPRT, "LI");
out.put("sender", sender);
}

if (idoc.findSegment("E1EDP20")!=null)
{
segment2 = idoc.findSegment("E1EDP20", "EDATU", "20991231");
while (segment2!=null)
{
idoc.removeSegment(segment2);
segment2 = idoc.findSegment("E1EDP20", "EDATU", "20991231");
}
segment3 = idoc.findSegment("E1EDP20", "EDATU", "");
while (segment3!=null)
{
idoc.removeSegment(segment3);
segment3 = idoc.findSegment("E1EDP20", "EDATU", "");
}
}
else
return Service.throwError("E1EDP20 does not exist");

idoc.commitChanges();
}

catch (Exception e)
{
out.copyFrom(Service.throwError(e));
}
-------------------------------------------------------------------------

Answer:
Do you really want to do this in Java? In a normal flow you could LOOP at /ORDERS04/E1EDP01/E1EDP20 and then BRANCH on the value of EDATU.
[BRANCH is like a CASE statement]

PS: You might try posting Business Connector questions to the Internet forum as well.
_________________
Rgds,
Derek
_________________
For formal [onsite | telephone | IM | email] support on SAP Business Connector and ITS, please contact me directly

Answer:
hmmm, yes, this would do the same for those cases where there are values (including nothing = empty) in E1EDP20; but can I branch if there is NO E1EDP20 at all? there is no "case: field does not exist" and I think there is no "branch: if field does not exist", or is it?

Thank You!
matt

Answer:
Hi,

For me the solution is to use sizeOfList which give the number of record on the record list E1EDP20.

Good Luck
SSII

Answer:
unfortunately I do not know what to do with your short message:
I tried
sizeOfList ("E1EDP20")
and
segment=idoc.findSegment("E1EDP20"); sizeOfList (segment)
but it does not compile, because the args are no "list" objects. I understand I should have a "list" Object but how do I get it from an Idoc?

Thank You for your help!

Answer:
Hi,

sizeOfList is a service so you should use it in the flow and not in a JAVA Service.

I hope it can help.
SSII

Answer:
In a normal flow service, use BRANCH and the $null option to check if the variable doesn't exist.
_________________
Rgds,
Derek
_________________
For formal [onsite | telephone | IM | email] support on SAP Business Connector and ITS, please contact me directly

Answer:
Thank You! Your idea (dcolley) is what I implemented during WE ... only using Java Mapping instead of the "graphical" tool's "BRANCH".

Thank you ssiii, it should work, but the classes available have no "sizexxx" method, therefore I abandoned that idea.

The key point is to find the class-docs, which are hidden within the BC-Integrator (doc/api/...) and BC-Server (doc/api/....) they say everything.

Here my version:

+++++++++++++++++++++ cut here +++++++++++++++++++

IDOCSegment segment2 = null;

/*--------------------------------------------------------------------
1. Check for first segment E1EDP20
2. Check whether field EDATU _seems_ to contain value
yes) could be null-pointer: remove
could be "20221231": remove
all other values: keep
no) empty field: remove
3. Check for next segment E1EDP20
from field: set to current segment index
4. Commit Changes
-------------------------------------------------------------------- */
segment2=idoc.findSegment("E1EDP20");
while (segment2!=null)
{
if (segment2.getSDATA("EDATU")!="")
{
if (segment2.getValues().getValues("EDATU")==null)
idoc.removeSegment(segment2);
else if (segment2.getSDATA("EDATU")=="20221231")
idoc.removeSegment(segment2);
}
else
{
idoc.removeSegment(segment2);
}
segment2=idoc.findSegment("E1EDP20",17);
/* this "17" needs to be replaced by the current segment index ... later */
}
idoc.commitChanges();

+++++++++++++++++++++ cut here +++++++++++++++++++
Copyright ?2007 - 2008 www.jt77.com