<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: idoc segment population logic needed in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/idoc-segment-population-logic-needed/m-p/4690037#M1102433</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As many entries you have in t_zchkhdr those many headers will be created for header and as many entries you have in t_zchkln , those many entries will be created in line.&lt;/P&gt;&lt;P&gt;I hope you have the occurences as 1 to many for lines.&lt;/P&gt;&lt;P&gt;Also you are distributing the IDoc within the loop at t_zchkhdr so one IDoc will be created per t_zchkhdr line.&lt;/P&gt;&lt;P&gt;If you want one Idoc containing all the headers, then move the MASTER_IDOC_DISTRIBUTE outside the outer loop. &lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Advait&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Advait Gode on Nov 5, 2008 3:46 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 05 Nov 2008 14:45:35 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-11-05T14:45:35Z</dc:date>
    <item>
      <title>idoc segment population logic needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/idoc-segment-population-logic-needed/m-p/4690036#M1102432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am creating a custom idoc. The custom idoc has one parent segment(zhead1) and a child segment(zinvoice). &lt;/P&gt;&lt;P&gt;I am populating the  invoice numbers(BELNR) and their line items in the child segment against a particular check number(PAYR_CHECT). &lt;/P&gt;&lt;P&gt;The structure is coming something like this: If a check has 2 different invoices each having two diff. line items, then  4child segment(containing invoice no. and it's respective line item in one child segment) is getting created against a parent segment(containing check header details).&lt;/P&gt;&lt;P&gt;But I require a parent segment to get populated against each check no. as well as invoice number and the invoice line items to be in the child segment of the invoice header segment.&lt;/P&gt;&lt;P&gt;How to do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My current code is:&lt;/P&gt;&lt;P&gt;LOOP AT T_ZCHKHDR INTO WA_ZCHKHDR.&lt;/P&gt;&lt;P&gt;    CLEAR T_IDOC_DATA.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Fill the header segment&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    ZCHKHDR-ZBUKR  = WA_ZCHKHDR-ZBUKR.&lt;/P&gt;&lt;P&gt;    ZCHKHDR-CHECT  = WA_ZCHKHDR-CHECT.&lt;/P&gt;&lt;P&gt;    ZCHKHDR-ZALDT  = WA_ZCHKHDR-ZALDT.&lt;/P&gt;&lt;P&gt;    ZCHKHDR-VOIDD  = WA_ZCHKHDR-VOIDD.&lt;/P&gt;&lt;P&gt;    ZCHKHDR-RWBTR  = WA_ZCHKHDR-RWBTR.&lt;/P&gt;&lt;P&gt;    ZCHKHDR-STATUS = WA_ZCHKHDR-STATUS.&lt;/P&gt;&lt;P&gt;    ZCHKHDR-BANKA  = WA_ZCHKHDR-BANKA.&lt;/P&gt;&lt;P&gt;    ZCHKHDR-RZAWE  = WA_ZCHKHDR-RZAWE.&lt;/P&gt;&lt;P&gt;    ZCHKHDR-XBLNR  = WA_ZCHKHDR-XBLNR.&lt;/P&gt;&lt;P&gt;    ZCHKHDR-LIFNR  = WA_ZCHKHDR-LIFNR.&lt;/P&gt;&lt;P&gt;    ZCHKHDR-WMWST1 = WA_ZCHKHDR-WMWST1.&lt;/P&gt;&lt;P&gt;    ZCHKHDR-BKTXT  = WA_ZCHKHDR-BKTXT.&lt;/P&gt;&lt;P&gt;    T_IDOC_DATA-SDATA = ZCHKHDR.&lt;/P&gt;&lt;P&gt;*-- Reduce fields for the segment&lt;/P&gt;&lt;P&gt;    CALL FUNCTION 'IDOC_REDUCTION_FIELD_REDUCE'&lt;/P&gt;&lt;P&gt;      EXPORTING&lt;/P&gt;&lt;P&gt;        MESSAGE_TYPE = C_MSG_TYPE&lt;/P&gt;&lt;P&gt;        SEGMENT_TYPE = C_SEGNAM_ZCHKHDR&lt;/P&gt;&lt;P&gt;        SEGMENT_DATA = T_IDOC_DATA-SDATA&lt;/P&gt;&lt;P&gt;        EMPTY_SYMBOL = C_SLASH&lt;/P&gt;&lt;P&gt;      IMPORTING&lt;/P&gt;&lt;P&gt;        SEGMENT_DATA = T_IDOC_DATA-SDATA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    T_IDOC_DATA-SEGNAM = C_SEGNAM_ZCHKHDR.&lt;/P&gt;&lt;P&gt;    T_IDOC_DATA-MANDT = SY-MANDT.&lt;/P&gt;&lt;P&gt;    APPEND T_IDOC_DATA.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Fill the item segment&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    LOOP AT T_ZCHKLN INTO WA_ZCHKLN WHERE CHECT = ZCHKHDR-CHECT.&lt;/P&gt;&lt;P&gt;      ZCHKLN-CHECT = WA_ZCHKLN-CHECT.&lt;/P&gt;&lt;P&gt;      ZCHKLN-EBELN = WA_ZCHKLN-EBELN.&lt;/P&gt;&lt;P&gt;      ZCHKLN-PO_EBELP = WA_ZCHKLN-PO_EBELP.&lt;/P&gt;&lt;P&gt;      ZCHKLN-PO_WERKS = WA_ZCHKLN-PO_WERKS.&lt;/P&gt;&lt;P&gt;      ZCHKLN-PO_KOSTL = WA_ZCHKLN-PO_KOSTL.&lt;/P&gt;&lt;P&gt;      ZCHKLN-PO_WBS = WA_ZCHKLN-PO_WBS.&lt;/P&gt;&lt;P&gt;      ZCHKLN-PO_SAKTO = WA_ZCHKLN-PO_SAKTO.&lt;/P&gt;&lt;P&gt;      ZCHKLN-BELNR = WA_ZCHKLN-BELNR.&lt;/P&gt;&lt;P&gt;      ZCHKLN-IN_BUZEI = WA_ZCHKLN-IN_BUZEI.&lt;/P&gt;&lt;P&gt;      ZCHKLN-IN_MENGE = WA_ZCHKLN-IN_MENGE.&lt;/P&gt;&lt;P&gt;      ZCHKLN-IN_MWSKZ = WA_ZCHKLN-IN_MWSKZ.&lt;/P&gt;&lt;P&gt;      ZCHKLN-IN_WRBTR = WA_ZCHKLN-IN_WRBTR.&lt;/P&gt;&lt;P&gt;      ZCHKLN-IN_BSTME = WA_ZCHKLN-IN_BSTME.&lt;/P&gt;&lt;P&gt;      T_IDOC_DATA-SDATA = ZCHKLN.&lt;/P&gt;&lt;P&gt;*-- Reduce fields for the segment&lt;/P&gt;&lt;P&gt;      CALL FUNCTION 'IDOC_REDUCTION_FIELD_REDUCE'&lt;/P&gt;&lt;P&gt;        EXPORTING&lt;/P&gt;&lt;P&gt;          MESSAGE_TYPE = C_MSG_TYPE&lt;/P&gt;&lt;P&gt;          SEGMENT_TYPE = C_SEGNAM_ZCHKLN&lt;/P&gt;&lt;P&gt;          SEGMENT_DATA = T_IDOC_DATA-SDATA&lt;/P&gt;&lt;P&gt;          EMPTY_SYMBOL = C_SLASH&lt;/P&gt;&lt;P&gt;        IMPORTING&lt;/P&gt;&lt;P&gt;          SEGMENT_DATA = T_IDOC_DATA-SDATA.&lt;/P&gt;&lt;P&gt;      T_IDOC_DATA-SEGNAM = C_SEGNAM_ZCHKLN.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     T_IDOC_DATA-HLEVEL = 2.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      T_IDOC_DATA-MANDT = SY-MANDT.&lt;/P&gt;&lt;P&gt;      APPEND T_IDOC_DATA.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;      CLEAR: WA_ZCHKLN.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;    AT LAST.&lt;/P&gt;&lt;P&gt;      PERFORM SUB_MASTER_IDOC_CONTROL.&lt;/P&gt;&lt;P&gt;      T_IDOC_HEADER-MESTYP = C_MSG_TYPE.&lt;/P&gt;&lt;P&gt;      T_IDOC_HEADER-IDOCTP = C_IDOC_TYPE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      SELECT SINGLE PARNUM FROM EDPP1&lt;/P&gt;&lt;P&gt;                           INTO V_SDNPRN&lt;/P&gt;&lt;P&gt;                           WHERE PARTYP = C_LS.             "#EC&lt;/P&gt;&lt;P&gt;      T_IDOC_HEADER-SNDPRN = V_SDNPRN.&lt;/P&gt;&lt;P&gt;      T_IDOC_HEADER-SNDPRT = C_LS.&lt;/P&gt;&lt;P&gt;      T_IDOC_HEADER-OUTMOD = C_OUTMOD.&lt;/P&gt;&lt;P&gt;      T_IDOC_HEADER-STDMES = C_STDMES.&lt;/P&gt;&lt;P&gt;      T_IDOC_HEADER-RCVPFC = V_RCVPFC.&lt;/P&gt;&lt;P&gt;      T_IDOC_HEADER-RCVPRN = V_RCVPRN.&lt;/P&gt;&lt;P&gt;      T_IDOC_HEADER-RCVPOR = V_RCVPOR.&lt;/P&gt;&lt;P&gt;      T_IDOC_HEADER-RCVPRT = C_LS.&lt;/P&gt;&lt;P&gt;      DESCRIBE TABLE T_IDOC_DATA LINES V_LINES.&lt;/P&gt;&lt;P&gt;      IF V_LINES &amp;gt; 0.&lt;/P&gt;&lt;P&gt;        CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'&lt;/P&gt;&lt;P&gt;          EXPORTING&lt;/P&gt;&lt;P&gt;            MASTER_IDOC_CONTROL            = T_IDOC_HEADER&lt;/P&gt;&lt;P&gt;          TABLES&lt;/P&gt;&lt;P&gt;            COMMUNICATION_IDOC_CONTROL     = T_COMM_IDOC_CONTROL&lt;/P&gt;&lt;P&gt;            MASTER_IDOC_DATA               = T_IDOC_DATA&lt;/P&gt;&lt;P&gt;          EXCEPTIONS&lt;/P&gt;&lt;P&gt;            ERROR_IN_IDOC_CONTROL          = 1&lt;/P&gt;&lt;P&gt;            ERROR_WRITING_IDOC_STATUS      = 2&lt;/P&gt;&lt;P&gt;            ERROR_IN_IDOC_DATA             = 3&lt;/P&gt;&lt;P&gt;            SENDING_LOGICAL_SYSTEM_UNKNOWN = 4&lt;/P&gt;&lt;P&gt;            OTHERS                         = 5.&lt;/P&gt;&lt;P&gt;        IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;          READ TABLE T_COMM_IDOC_CONTROL INTO WA_COMM_IDOC_CONTROL INDEX 1.&lt;/P&gt;&lt;P&gt;          IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;            MESSAGE S000(ZFI) WITH WA_COMM_IDOC_CONTROL-DOCNUM.&lt;/P&gt;&lt;P&gt;          ENDIF.&lt;/P&gt;&lt;P&gt;        ELSE.&lt;/P&gt;&lt;P&gt;          MESSAGE W001(ZMM) WITH TEXT-003.&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;      CLEAR T_IDOC_DATA.&lt;/P&gt;&lt;P&gt;      REFRESH T_IDOC_DATA.&lt;/P&gt;&lt;P&gt;    ENDAT.&lt;/P&gt;&lt;P&gt;    CLEAR: WA_ZCHKHDR.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sangeeta.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2008 14:34:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/idoc-segment-population-logic-needed/m-p/4690036#M1102432</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-05T14:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: idoc segment population logic needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/idoc-segment-population-logic-needed/m-p/4690037#M1102433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As many entries you have in t_zchkhdr those many headers will be created for header and as many entries you have in t_zchkln , those many entries will be created in line.&lt;/P&gt;&lt;P&gt;I hope you have the occurences as 1 to many for lines.&lt;/P&gt;&lt;P&gt;Also you are distributing the IDoc within the loop at t_zchkhdr so one IDoc will be created per t_zchkhdr line.&lt;/P&gt;&lt;P&gt;If you want one Idoc containing all the headers, then move the MASTER_IDOC_DISTRIBUTE outside the outer loop. &lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Advait&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Advait Gode on Nov 5, 2008 3:46 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2008 14:45:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/idoc-segment-population-logic-needed/m-p/4690037#M1102433</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-05T14:45:35Z</dc:date>
    </item>
  </channel>
</rss>

