Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Bad data added in Open Dataset for output in Binary mode

former_member498250
Participant
0 Kudos
253

Hello,

I am getting random bad data being added to the end of the file that is created on the file server when I run the Open Dataset for output in Binary mode. This data sometimes looks like information about the Unix file server. If I do the Open Dataset in Text mode, it does not add the extra bad data.

 ** transfer file to Unix File server
       DATA: LIN TYPE P.
                                                                                OPEN DATASET P_APPFIL FOR OUTPUT IN BINARY MODE.
                                                                                DESCRIBE TABLE XML_TAB LINES LIN.
                                                                                IF LIN EQ 0.
         EXIT.
       ELSE.
         LOOP AT XML_TAB.
           TRANSFER XML_TAB TO P_APPFIL.
         ENDLOOP.
       ENDIF.
                                                                                CLOSE DATASET P_APPFIL. 

Running the program 2 times with the same variant will give different results.

For example, the data in file should end with </cPedigreeXML> but it added data as shown below:

</cPedigreeXML>8 ˜ I X-UNKNOWN 9 œ I X-UNKNOWN 10

  C X-UNKNOWN

Then, when the program was run again with the same selections, it did not add the erroneous data at the end.

This is a real problem because the bad data that gets added causes the file to error in the application. Any help would be greatly appreciated.

Thanks,

Bob

5 REPLIES 5

Former Member
0 Kudos
76

Can you move the XML_TAB line to a single field (say ws_line(80) type c) and write this to the file? It might be due to a structure being transferred in binary mode.

Let us know how it goes.

Former Member
0 Kudos
76

Hi Bob,

Use CLEAR statement after TRANSFER statement and check once.

IF LIN EQ 0.

EXIT.

ELSE.

LOOP AT XML_TAB.

TRANSFER XML_TAB TO P_APPFIL.

<b>CLEAR XML_TAB.</b>

ENDLOOP.

ENDIF.

Thanks,

Vinay

0 Kudos
76

I feel that it must be something that is happening when the last line is transferred. I ran the same variant 4 more times and it did not add any of the extra data. Other times when this was in our quality system, I ran the program several times with using the same variant, and each time it added something different on the last line. Our EDI person created a script to remove this at the unix level, but I would like to find the how and why this happens

0 Kudos
76

Use Length option in TRANSFER statement.

Calculate last line length using strlen() and ue the length in the transfer statement.

Regards

Sridhar

0 Kudos
76

Hi,

I tried this but since the data line is hex it always comes up with a length of 256 ( DATA: XML TYPE DCXMLLINES )