Author |
Message
|
bobbee |
Posted: Fri Mar 27, 2015 1:59 am Post subject: OCCURS DEPENDING ON |
|
|
 Knight
Joined: 20 Sep 2001 Posts: 545 Location: Tampa
|
I have a C program building a structure. I have to move this logic into WMB. So I have the structure built in a COPYBOOK. In RFHUTIL it matches up but is not showing me the repeating outter group. I have 1-n repeating segments each of which contain a length followed by a variable length of characters. Is this definable in COBOL?
05 SEGMENTS OCCURS NUM-SEGS TIMES.
10 SEGMENT_LEN PIC 9(04).
10 SEGMENT PIC X(01) OCCURS 1055 times
DEPENDING on SEGMENT-LEN. |
|
Back to top |
|
 |
kimbert |
Posted: Fri Mar 27, 2015 3:51 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Is this definable in COBOL? |
So you are trying to model this structure by
- creating a COBOL copybook that describes the structure
- importing the copybook to create a DFDL schema
Is that correct? _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
bobbee |
Posted: Fri Mar 27, 2015 4:00 am Post subject: |
|
|
 Knight
Joined: 20 Sep 2001 Posts: 545 Location: Tampa
|
Yes, that is my typical approach. Easy to get a 'starting' doc for me. I was told to get close and then go in and modify the DFDL. I know the outter DEPENDS ON works. i think i remember that that inner one is not legal. So I may have to eliminate that. Import/Build and then go in and muck with the length modifiers. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Mar 27, 2015 5:00 am Post subject: Re: OCCURS DEPENDING ON |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
bobbee wrote: |
I have a C program building a structure. I have to move this logic into WMB. So I have the structure built in a COPYBOOK. In RFHUTIL it matches up but is not showing me the repeating outter group. I have 1-n repeating segments each of which contain a length followed by a variable length of characters. Is this definable in COBOL?
Code: |
05 SEGMENTS OCCURS NUM-SEGS TIMES.
10 SEGMENT_LEN PIC 9(04).
10 SEGMENT PIC X(01) OCCURS 1055 times
DEPENDING on SEGMENT-LEN. |
|
Your occurs depending on syntax doesn't seem quite right.
From memory I thought it would be occurs variable times depending on
or occurs up to n times depending on...or something like that... _________________ MQ & Broker admin |
|
Back to top |
|
 |
kimbert |
Posted: Fri Mar 27, 2015 7:47 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I was told to get close and then go in and modify the DFDL. |
I think now is the time to go in and modify the DFDL. Unless you really need a COBOL version of your data structure.
OCCURS DEPENDING ON translates to this DFDL:
Occurs Count Kind='expression'
Occurs Count = <an XPath expression pointing to the count>
Quote: |
I have 1-n repeating segments each of which contain a length followed by a variable length of characters |
This nicely illustrates the limitations of your C -> COBOL -> DFDL strategy. What you are really describing is a variable length string. Not a variable-length array of single characters.
A variable-length string is modeled like this in DFDL:
Length Kind = 'explicit'
Length = <an XPath expression pointing to the count> _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
bobbee |
Posted: Fri Mar 27, 2015 12:10 pm Post subject: |
|
|
 Knight
Joined: 20 Sep 2001 Posts: 545 Location: Tampa
|
Some how kimbert your response blew out of my mailbox and i did not see an update.
You are correct. It is a variable length string and not an array of single bytes. I figured out this eror in my formation of the COBOL copybook when I built the DFDL in IIB.
It all seems to work down to the COMP_IDOC_SEGMENT. When I say EXPLICIT and point to the SEGMENT_LEN it wants an index. If I click the checkbox to ignore the expected happens. It uses the first length for all. So I see the first and second message, then it starts going bad. I guess if I put a 1 in there I will get the same. How do I tell it to use the current SEGMENT_LEN pointed to by IDOC_SEGMENTS. I know the what, I do not know the how. I tried {dfdl:self} thinking 'maybe, but no. |
|
Back to top |
|
 |
kimbert |
Posted: Fri Mar 27, 2015 1:26 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
OK - I have a better idea. You are fortunate because the length comes immediately before the variable-length string. So you can model this as
- Length Kind=prefixed
- Prefix Length Type=<name of an integer type>
The <name of an integer type> should name a global simple type.
SEGMENT_LEN is a global simple element, and its type is the one that you need to use. If you're lucky, the COBOL importer will be using a global simple type for SEGMENT_LEN and you can
- set that simple type as the Prefix Length Type
- delete SEGMENT_LEN because it it now being modelled as the prefix length
( and note that the SEGMENT_LEN field will not appear in the message tree after this ).
If you are not so lucky, SEGMENT_LEN will have a local simple type, and you will need to refactor it to a global simple type before proceeding. Post again if you need to do that and don't know how. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
bobbee |
Posted: Fri Mar 27, 2015 2:08 pm Post subject: |
|
|
 Knight
Joined: 20 Sep 2001 Posts: 545 Location: Tampa
|
If I understand you correctly, that would cause me a problem. this is an output tree. I am building this from a SAP IDOC and compressing the segments. That is what the SEGMENT_LEN and SEGMENT is. The receiving side is expecting the 4 byte len and then the segment imed following it. Is it magic that the len will not appear or is it physically not there. So I guess we may be talking about tow things. The representation in the DFDL tester and what I will eventually use in the flow.
But I will try what you suggested. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Mar 27, 2015 6:46 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Hi Bobee,
How are you compressing the segments? To mimic the generic way SAPIDOC to file works, you take the IDOC_DD40 length 1063 and you trim it. EOL should then determine the end of the segment / file. If memory serves well. The problem is the last fields on the segment. If they are empty or only partially filled. The length of the actual data on the IDOC_DD40 is determined by the type of segment (structure) and must fit into 1000 bytes. the first 63 bytes contain segment name (determines structure in the SDATA section), idoc id, position, hierarchy and some other information I have forgotten...
So if the length is less than the segment length it is safe to append spaces until segment length is reached...
The unused part on the SDATA (blank after segment length) always needs to be initialized to avoid leftover data from a previous (longer) segment.
Been years since I actively worked with IDOCs. Hope my memory is not too clouded.
So one possibility would be to trim the SDATA (defined for max 1000 bytes) and add the EOL as a postfix delimiter?. Make it length delimited. postfix delimiter EOL.
When trying to parse get the SDATA as delimited EOL, Then expand it to 1000 bytes by padding with spaces. With that you have the segment and Filler.
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
kimbert |
Posted: Sat Mar 28, 2015 4:01 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
SEGMENT_LEN will be represented in the output bit stream. But you will not need to create an element called 'SEGMENT_LEN' in the message tree. DFDL will calculate the length of the character string and automatically write SEGMENT_LEN using the DFDL properties on the global simple type ( the one specified in Prefix Length Type ). _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Mar 28, 2015 12:59 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
kimbert wrote: |
SEGMENT_LEN will be represented in the output bit stream. But you will not need to create an element called 'SEGMENT_LEN' in the message tree. DFDL will calculate the length of the character string and automatically write SEGMENT_LEN using the DFDL properties on the global simple type ( the one specified in Prefix Length Type ). |
Ahhh but segment length is something that is determined in SAP when defining the segment and cannot always be inferred from the record because of trimming the trailing blanks... So segment length should be carried on the EDI_DD40 first 63 bytes and on the message tree...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|