Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to generate flat file

Hi All,

My scenario is : EDI - SAP PO - File(.txt)

SAP PO  pull the EDI file and  It generate the field fixed lengths file to target.

In my source file  The HDR segment and  DTL segments are repeating  as mention below

.

.

HDR~HDR1~HDR2|

DTL~DATA1~DATA2|

DTL~DATA1~DATA2|

DTL~DATA1~DATA2|

DTL~DATA1~DATA2|

HDR~HDR1~HDR2|

DTL~DATA1~DATA2|

DTL~DATA1~DATA2|

HDR~HDR1~DHDR2|

DTL~DATA1~DATA2|

.

.The Source XML like as below ..

  <L_HDR>

      <S_HDR>

         <FIELD1>HDR1<FIELD1>

         <FIELD2>HDR2</FIELD2>

      </S_HDR>

      <L_DTL>

         <S_DTL>

           <FIELD1>DATA1<FIELD1>

           <FIELD2>DATA2</FIELD2>

         </S_DTL>

      </L_DTL>

      <L_DTL>

          <S_DTL>

            <FIELD1>DATA1<FIELD1>

             <FIELD2>DATA2</FIELD2>

          </S_DTL>

       </L_DTL>

       <L_DTL>

           <S_DTL>

             <FIELD1>DATA1<FIELD1>

             <FIELD2>DATA2</FIELD2>

           </S_DTL>

       </L_DTL>

   </L_HDR>

  <L_HDR>

        <S_HDR>

             <FIELD1>HDR1<FIELD1>

            <FIELD2>HDR2</FIELD2>

         </S_HDR>

       <L_DTL>

         <S_DTL>

            <FIELD1>DATA1<FIELD1>

             <FIELD2>DATA2</FIELD2>

         </S_DTL>

       </L_DTL>

       <L_DTL>

           <S_DTL>

             <FIELD1>DATA1<FIELD1>

              <FIELD2>DATA2</FIELD2>

           </S_DTL>

        </L_DTL>

  </L_HDR>

i Want to generate flat file to target. the format of flat file is shown below

CONSTANT H CONSTANT H       //HEADDER DATA OF HDR

HDR1              HDR2                           // HDR DATA

CONSTANT D CONSTANT D        //HEADDER DATA OF DTL

DATA1            DATA2

DATA1            DATA2                         //DTL DATA

DATA1            DATA2

CONSTANT H CONSTANT H        //HEADDER DATA OF HDR

HDR1              HDR2                           // HDR DATA

CONSTANT D CONSTANT D       //HEADDER DATA OF DTL

DATA1            DATA2

DATA1            DATA2                         //DTL DATA

CONSTANT H CONSTANT H        //HEADDER DATA OF HDR

HDR1              HDR2                           // HDR DATA

CONSTANT D CONSTANT D       //HEADDER DATA OF DTL

DATA1            DATA2                         //DTL DATA

please advise me the target stricture and looping LOGIC OF of Header Data of HDR,HDR,Header Data of DTL,DTL  segments

Former Member
Not what you were looking for? View more on this topic or Ask a question