Idoc no in internal table

hi
  i have a requirement where i have to get  idoc no along with the delivery details  into internal table.
is there any function module to get tht idoc no into internal table .
regards

Hello pavan,
use FM
EDI_DOCUMENT_OPEN_FOR_READ and EDI_SEGMENTS_GET_ALL
and get these values in an internal table.
or you can get the values of IDOC from Table EDIDC and EDIDD for particular idoc number
Reward for helpful answer.
Thanks,
Gunjan

Similar Messages

  • How to read data from idoc to internal table?

    Hi
    How to get data from idoc segments to internal table?

    Hi
    Check this ex
    The following coding sample, shows how you may read a MATMAS IDoc and extract the data for the MARA and MARC segments to some internal variables and tables.
    DATA: xmara LIKE mara.
    DATA: tmarc LIKE marc
                OCCURS 0
                WITH HEADER LINE.
    LOOP AT edidd.
       CASE edidd-segnam.
         WHEN 'E1MARAM'.
              MOVE edidd-sdata TO xmara.
         WHEN 'E1MARCM'.
           MOVE edidd-sdata TO tmarc.
              APPEND tmarc.
       ENDCASE.
    ENDLOOP.
    now do something with xmara and tmarc.
    hope this helps you...
    Reward points if useful..
    Regards
    Sreenivas

  • How to send Internal table records to Idoc Inbound posting FM to create Ido

    Hello Experts,
    I have all the data necessary to create shipments in one internal table inside my ABAP program.
    I can use BAPI_SHIPMENT_CREATE to create shipments. But associated with this BAPi there is one ALE message type SHIPMENT_CREATEFROMDATA. Now my requirement is to use this message type to cretae my shipments via idocs for one scenario for some of the records in the internal table.
    For this message type, I got the inbound function module IDOC_INPUT_SHIPMENT_CREATEFROM from TBDBE table.
    Can anybody please let me know how to send the data from the internal table to this inbound function  module?
    Becasue it has mandatory parameters INPUT_METHOD, MASS_PROCESSING. What values should be passed to these parameters if the data has to be sent to this function module?
    Regards.

    Hi Ravikanth,
    Thankyou very much for your quick reply.
    So If I split my internal table data and populate IDOC_DATA and IDOC_CONTROL and pass to the inbound function module directly in my ABAP program, will that be going to create idocs and post shipments?
    I mean is it enough to call the Inbound posting function module directly in my ABAP program or any other FMs to be called to take care of ALE settings and shipment creation?
    Please confirm.
    REgards.

  • Read MULTIPLE idocs data with all sgmn to my internal table in a single

    Dear SAP Folks!
    I have a question, I know to read SINGLE idoc data with all segments, we have FM IDOC_READ_COMPLETELY but my requirement is to Read MULTIPLE idocs data with all segments to my internal table in a single shot without keeping this FM in loop! since it is performance issue, at a time i may want to read 1000 idocs data!
    Could anyone please let me know is there any way to get this, keeping mind of performance and any other FM?
    Best Regards,
    Srini

    Hi,
    I know idoc numbers and i can write a select Query to DB table EDID4 to get all segments data to my internal table. But i am looking for FM to do this. because i have too many number of idocs and each idoc is having many segments(I am thinking in performance point of view!) The FM IDOC_READ_COMPLETELY can accept only ONE IDOC number as import parameters at a time to get segment data. in similar way do we have any other FM? or other way? except select query to EDID4 table?
    Best Regards,
    Srini

  • Transfer IDOC File in a Internal Table

    Hi all,
    I need to Transfer IDOC File in a Internal Table.
    Anybody have any idea how  can I do this???
    Regards,

    HI,
    is the IDoc exist in SAP?if IDoc exist in SAP you can use one function module to read the idoc and store tha content in internal table.
    IDOC_READ_COMPLETELY function module will read the specified idoc number.you can retrieve the control records ,status records and the data record of the idoc.for this you have to declare 3 internal tables (check the function modules for the type of inerna table).you can then loop the internal table and read the data.let us know if u have any problems
    regards
    shibu

  • How to pass the contents of an internal table to the IDoc FIDCC2?

    Hi,
    I have an internal table. Using its contents, I have to create an Idoc and do GL posting.
    I have to use FIDCC2 Idoc and the function module IDOC_INPUT_FIDCC2.
    Can u please let me know how to pass the contents of the internal table into the idoc FIDCC2 and do the GL posting?
    Regards,
    Balaji. R

    Hi balaji,
    use function IDOC_INBOUND_FROM_FILE. This will do half the process.
    Documentation is missing, but program RSEINB00 explains something,
    also some links
    [http://help.sap.com/saphelp_nw70/helpdata/EN/dc/6b7f1543d711d1893e0000e8323c4f/frameset.htm]
    [RSEINB00 does not work in background]
    [RSEINB00 flat file to idoc uploading in XI]
    [Loading flat idoc via report RSEINB00 into integration server fails]
    Hope it helps.
    Regards,
    Clemens

  • Create internal table dynamically for IDoc fields

    Hi,
    I need to create an internal table dynamically based on the segment field names that are returned in the table pt_fields when calling function 'IDOCTYPE_READ_COMPLETE'.  I see many posts suggesting classes such as 'cl_wrf_dynamic_table=>create_dynamic_table', but it does not work for me.  The problem I have with the classes is that it doesn't allow you to have the same column name more than once.  But in the scenario I am testing, I have some column names that are duplicated, and I cannot remove the duplicates.  Are there any functions or classes that I can use to create a dynamic internal table that will not check if a column name is used twice?
    Thanks,
    Carrie

    Hello Carrie
    My first thought was that RTTI might be able to do this but it does not (see the dump below). And it is obvious that RTTI behave likes this.
    Error analysis
        An exception occurred which is explained in detail below.
        The exception, which is assigned to class 'CX_SY_STRUCT_COMP_NAME', was not
         caught and
        therefore caused a runtime error.
        The reason for the exception is:
        Multiple Specification of the Name 'CUSTOMER' as a Component Name (Component 7)
    Just think about any way  to define statically an itab or structure containing duplicated field names. You will always get a syntax error irrespective of whether you use a DDIC structure, a TYPE or a DATA variable.
    If there is no way to define such a structure statically why should it be different when defining dynamically?
    Regards
      Uwe

  • How to populate field catalogue fields in ALV using  dynamic internal table

    Hi All,
    Please let me know how to populate field catalogue fields in ALV using  dynamic internal table.
    I have created <dyn_table> using code below.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
                     EXPORTING
                       it_fieldcatalog = g_t_ifc
                        it_fieldcatalog = g_t_fieldcat
                     IMPORTING
                        ep_table        = dy_table.
      ASSIGN dy_table->* TO <dyn_table>.
    Create dynamic work area and assign to FS
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.
    Now this  <dyn_table>  has fields like idoc no.,creation date ,
    segment field 1, segment field 2 etc..Now idoc no.,creation date  are static fields from table EDIDC. And segment field 1, segment field 2 etc are dynamic fields from table EDSAPPL.
    In my  ALV report I am getting the final layout properly but I am unable to move values to corresponding fields in the final layout shown.Please let me know how to populate these fields from different tables.
    I tried this way but its not working.
    SORT g_t_edid4 BY docnum.
      LOOP AT g_t_edidc INTO g_r_edidc.
        READ TABLE g_t_edid4 into g_r_edid4
                         WITH KEY docnum = g_r_edidc-docnum
                                        BINARY SEARCH.
        IF sy-subrc = 0.
          <dyn_wa> =  g_r_edid4-sdata.
         MOVE-CORRESPONDING g_r_edid4 to <dyn_wa>.
       CLEAR g_r_edid4.
        ENDIF.
    MOVE-CORRESPONDING g_r_edidc to <dyn_wa>.
    APPEND <dyn_wa> TO <dyn_table>.

    You have to assign each field to field symbol and then assign the value to that field symbol and asssign that field symbol to workarea field symbol.
    LOOP AT g_t_edidc INTO g_r_edidc.
    READ TABLE g_t_edid4 into g_r_edid4
    WITH KEY docnum = g_r_edidc-docnum
    BINARY SEARCH.
    IF sy-subrc = 0.
    ASSIGN COMPONENT 'SDATA' OF STRUCTURE <DYN_WA> TO <DYN_FLD>.
    <DYN_FLD> = g_r_edid4-sdata.
    " <dyn_wa> = g_r_edid4-sdata.
    " Assign each fields like this.
    " MOVE-CORRESPONDING g_r_edid4 to <dyn_wa>.
    CLEAR g_r_edid4.
    ENDIF.
    " MOVE-CORRESPONDING g_r_edidc to <dyn_wa>.
    APPEND <dyn_wa> TO <dyn_table>.
    Regards,
    Naimesh Patel

  • EXPORT STATEMENT fro INTERNAL TABLE VALUES

    Hi,
    From one program I am calling my program using SUBMIT statement.
    In the subprogram, I will be doing som process.If I get any error message I am storing in an internal table.
    This internal table has to come to the main program.
    So that I will create an Idoc in main program for all the error messages.
    For this I am using EXPORT IMPORT statements.
      wa_idoc_msg-type = text-003.
      wa_idoc_msg-id =  'ZLES'.
      wa_idoc_msg-number = '477'.
      append wa_idoc_msg to t_idoc_msg.
      clear wa_idoc_msg.
      exit.
      export (T_IDOC_MSG) to memory id 'T_IDOC_MSG'.
    Now In this export line, I am getting error as ZLES not able to recognize.
    Help required for this issue.

    Hi,
    Check the below link
    http://www.sap-img.com/abap/difference-between-sap-and-abap-memory.htm
    Regards,
    nagaraj

  • XML to internal table conversion within ABAP mapping class

    I am doing a ABAP mapping for file to Idoc. My requirement is to convert XML file into ABAP internal table (within ABAP mapping class). Is there any standard FM, method, transformation etc, which can be used here.
    Thanks, Dehra

    Dehra,
    Have you seen this weblogs which talks about this:
    /people/r.eijpe/blog/2005/11/10/xml-dom-processing-in-abap-part-i--convert-an-abap-table-into-xml-file-using-sap-dom-approach
    /people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
    /people/r.eijpe/blog/2006/02/19/xml-dom-processing-in-abap-part-iiia150-xml-dom-within-sap-xi-abap-mapping
    /people/r.eijpe/blog/2006/02/20/xml-dom-processing-in-abap-part-iiib150-xml-dom-within-sap-xi-abap-mapping
    Hope this helps you....
    ---Satish

  • Creating XML transformation using multiple internal tables

    <b>Hi everyone,</b><br />
    <br />
    <b>I'm trying to transforme 3 internal tables (from customer master data) into a single XML document.</b><br />
    <p />
    DATA:   BEGIN OF wtab OCCURS 0 ,<br />
            kunnr LIKE kna1-kunnr, "Customer ID<br />
            ktokd LIKE kna1-ktokd, <br />
            land1 LIKE kna1-land1, <br />
            name1 LIKE kna1-name1, <br />
            ort01 LIKE kna1-ort01, <br />
            pstlz LIKE kna1-pstlz, <br />
            spras_iso LIKE kna1-spras, <br />
            smtp_addr LIKE adr6-smtp_addr, <br />
            stras LIKE kna1-stras, <br />
              END OF wtab.<br />
    <br />
    DATA:   BEGIN OF wtab_o OCCURS 0 ,<br />
            kunnr LIKE knvv-kunnr, "Customer ID<br />
            vkorg LIKE knvv-vkorg, "Sales organisation<br />
            waers LIKE knvv-waers, <br />
            END OF wtab_o.<br />
    <br />
    DATA:   BEGIN OF wtab_p OCCURS 0 ,<br />
            kunnr LIKE knvp-kunnr, "Customer ID<br />
            vkorg LIKE knvp-vkorg, "Sales organisation<br />
            parvw LIKE knvp-parvw, <br />
            kunn2 LIKE knvp-kunnr,<br />
              END OF wtab_p.<br />
    <p />
    <b>The internal tables are related to each other as follows:*</b><br />
    <br />
    wtab-kunnr = wtab_o-kunnr<br />
    <br />
    AND<br />
    <br />
    wtab_o-vkorg = wtab_p-vkorg<br />
    wtab_o-kunnr = wtab_p-kunnr<br />
    <br />
    <b>I couldn't figure out how to declare this relationship when calling the transformation. Is it possible?</b><br />
    <p />
    ABAP<br />
    <br />
    <br />
    REFRESH : gt_source_itab.<br />
    CLEAR : g_rxml.<br />
    <br />
      GET REFERENCE OF wtab INTO gs_source_wa-value.<br />
      gs_source_wa-name = 'DEBMAS04'.<br />
      APPEND gs_source_wa TO gt_source_itab.<br />
    <br />
      GET REFERENCE OF wtab_o INTO gs_source_wa-value.<br />
      gs_source_wa-name = 'E1KNVVM'.<br />
      APPEND gs_source_wa TO gt_source_itab.<br />
    <br />
    GET REFERENCE OF wtab_p INTO gs_source_wa-value.<br />
      gs_source_wa-name = 'E1KNVPM'.<br />
      APPEND gs_source_wa TO gt_source_itab.<br />
    <br />
      TRY.<br />
          CALL TRANSFORMATION Z_XSLT_CLIENT<br />
          SOURCE (gt_source_itab)<br />
          RESULT XML g_rxml<br />
          OPTIONS xml_header = 'without_encoding'.<br />
    CATCH cx_root INTO gs_rif_ex.<br />
    <br />
          gs_var_text = gs_rif_ex-&gt;get_text( ).<br />
          MESSAGE gs_var_text TYPE 'E'.<br />
        ENDTRY.<br />
    <br />
    <br />
    Transformation Z_XSLT_CLIENT:<br />
    <br />
    <br />
    &lt;xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   xmlns:sap="http://www.sap.com/sapxsl"&gt;<br />
    &lt;xsl:output indent="yes" encoding="UTF-16" method="xml" version="1.0"/&gt;<br />
    &lt;xsl:strip-space elements="*"/&gt;<br />
    &lt;xsl:template match="/"&gt;<br />
    &lt;DEBMAS04&gt;<br />
    &lt;xsl:apply-templates select="//DEBMAS04/item"/&gt;<br />
    &lt;/DEBMAS04&gt;<br />
    &lt;/xsl:template&gt;<br />
    &lt;xsl:template match="DEBMAS04/item"&gt;<br />
         &lt;IDOC&gt;<br />
           &lt;xsl:attribute name="BEGIN"&gt;1&lt;/xsl:attribute&gt;<br />
           &lt;E1KNA1M&gt;<br />
            &lt;xsl:attribute name="SEGMENT"&gt;1&lt;/xsl:attribute&gt;<br />
            &lt;KUNNR&gt;<br />
               &lt;xsl:value-of select="KUNNR"/&gt;<br />
            &lt;/KUNNR&gt;<br />
            &lt;KTOKD&gt;<br />
               &lt;xsl:value-of select="KTOKD"/&gt;<br />
            &lt;/KTOKD&gt;<br />
            &lt;LAND1&gt;<br />
               &lt;xsl:value-of select="LAND1"/&gt;<br />
            &lt;/LAND1&gt;<br />
            &lt;NAME1&gt;<br />
               &lt;xsl:value-of select="NAME1"/&gt;<br />
            &lt;/NAME1&gt;<br />
            &lt;ORT01&gt;<br />
               &lt;xsl:value-of select="ORT01"/&gt;<br />
            &lt;/ORT01&gt;<br />
            &lt;PSTLZ&gt;<br />
               &lt;xsl:value-of select="PSTLZ"/&gt;<br />
            &lt;/PSTLZ&gt;<br />
            &lt;SPRAS_ISO&gt;<br />
               &lt;xsl:value-of select="SPRAS_ISO"/&gt;<br />
            &lt;/SPRAS_ISO&gt;<br />
            &lt;SMTP_ADDR&gt;<br />
               &lt;xsl:value-of select="SMTP_ADDR"/&gt;<br />
            &lt;/SMTP_ADDR&gt;<br />
            &lt;STRAS&gt;<br />
               &lt;xsl:value-of select="STRAS"/&gt;<br />
            &lt;/STRAS&gt;<br />
             &lt;xsl:apply-templates select="//E1KNVVM/item"/&gt;<br />
           &lt;/E1KNA1M&gt;<br />
      &lt;/IDOC&gt;<br />
    &lt;/xsl:template&gt;<br />
    &lt;xsl:template match="E1KNVVM/item"&gt;<br />
       &lt;E1KNVVM&gt;<br />
             &lt;xsl:attribute name="SEGMENT"&gt;1&lt;/xsl:attribute&gt;<br />
             &lt;VKORG&gt;<br />
               &lt;xsl:value-of select="VKORG"/&gt;<br />
             &lt;/VKORG&gt;<br />
             &lt;WAERS&gt;<br />
               &lt;xsl:value-of select="WAERS"/&gt;<br />
             &lt;/WAERS&gt;<br />
           &lt;xsl:apply-templates select="//E1KNVPM/item"/&gt;<br />
       &lt;/E1KNVVM&gt;<br />
    &lt;/xsl:template&gt;<br />
    &lt;xsl:template match="E1KNVPM/item"&gt;<br />
       &lt;E1KNVPM&gt;<br />
             &lt;xsl:attribute name="SEGMENT"&gt;1&lt;/xsl:attribute&gt;<br />
             &lt;PARVW&gt;<br />
               &lt;xsl:value-of select="PARVW"/&gt;<br />
             &lt;/PARVW&gt;<br />
             &lt;KUNN2&gt;<br />
               &lt;xsl:value-of select="KUNN2"/&gt;<br />
             &lt;/KUNN2&gt;<br />
       &lt;/E1KNVPM&gt;<br />
    &lt;/xsl:template&gt;<br />
    &lt;/xsl:transform&gt;<br />
    <br />
    <b>The way the call transformation is now, for each line in table wtab (DEBMAS04) I'm getting all the lines in table wtab_o (E1KNVVM) and table wtab_p (E1KNVPM)</b><br />
    <p />
    <br />
    Thank you for your help,<br />
    <br />
    Giselle<br />
    <p />

    Hi Giselle,
    I think it's possible (using xsl:if for instance), but an easier way is to nest your internal tables declarations (wtab_o inside wtab, kunnr becomes useless, and wtab_p inside wtab_o), and use the SAP standard "ID" transformation (no need for a custom XSL transformation). You'll get a slightly different result, but I don't think you want something very sophisticated.
    Sandra

  • Logic in internal table -- Urgent

    Hi All,
    I have an internal table idoc_data of structure
          DOCNUM  SEGNUM  SEGNAM       
          3164     00001  E1STZUM -
    1st idoc
          3164     00002  E1MASTM
          3164     00003  E1MARAM
          3164     00004  E1MAKTM
          3164     00005  E1STPOM -
    end of 1st idoc
          3164     00006  E1STZUM  -
    2nd idoc
          3164     00007  E1MASTM
          3164     00008  E1MARAM
          3164     00009  E1STPOM -
    end of 2nd idoc
          3164     00010  E1STZUM  -
    3rd idoc
          3164     00011  E1MASTM
          3164     00012  E1MARAM
          3164     00013  E1STPOM  -
    end of 3rd idoc
          and so on .........
    "Pls note that the idocs are collected into a single idoc having same DOCNUM 3164".
    I have to write a logic like this.
    Loop at idoc_data.
    Move the first idoc record starting from E1STZUM -
    1st idoc till E1STPOM----end of 1st idoc into a temporary internal table and call master_idoc_distribute to send an idoc out.
    Move the second idoc record starting from E1STZUM  -
    2nd idoc till E1STPOM -
    end of 2nd idoc into the temporary internal table and call master_idoc_distribute to send an idoc out.
    Move the third idoc like the same and so on........for the whole idocs. 
    There could be even more than 5000 idocs in the same structure having same idoc number.
    Any help in writing the logic is really appreciated. Pls send me the whole code itself. It is an urgent reqmt. So pls do the needful.....
    Thanks
    Ricky

    Will explain one more time.
    Internal table structure
    DOCNUM SEGNUM SEGNAM
    3164 00001 E1STZUM -
    1st idoc
    3164 00002 E1MASTM
    3164 00003 E1MARAM
    3164 00004 E1MAKTM
    3164 00005 E1STPOM
    3164 00006 Z1MARZ -
    end of 1st idoc (this could be more than one )
    3164 00007 E1STZUM -
    2nd idoc
    3164 00008 E1MASTM
    3164 00009 E1MARAM
    3164 00010 E1STPOM
    3164 00011 Z1MARZ -
    end of 2nd idoc (this could be more than one)
    3164 00010 E1STZUM -
    start of 3rd idoc
    3164 00011 E1MASTM
    3164 00012 E1MARAM
    3164 00013 E1STPOM
    3164 00014 Z1MARZ     -
    end of 3rd idoc (this could be more than one)
    and so on.........
    "Pls note that the idocs are collected into a single idoc having same DOCNUM 3164".
    I have to write a logic like this.
    Loop at idoc_data.
    Move the first idoc record starting from E1STZUM -
    1st idoc till Z1MARZ----end of 1st idoc into a temporary internal table and call '' FM master_idoc_distribute'' to send an idoc out.
    Move the second idoc record starting from E1STZUM -
    2nd idoc till Z1MARZ -
    end of 2nd idoc into the temporary internal table and call FM "master_idoc_distribute" to send an idoc out.
    Move the third idoc like the same and so on........for the whole idocs.
    There could be even more than 5000 idocs in the same structure having same idoc number.
    Any help in writing the logic is really appreciated. Pls send me the whole code itself. It is an urgent reqmt. So pls do the needful.....
    Thanks

  • Is it possible to create an internal table in XI??

    Hi Experts,
    My scenario is IDoc to JDBC. Some fields are direct mapping but where in my requirement is like this.
    Need to create one internal table with 6 fields. In this one field would be Counter and remaining are populated with the IDoc fields data. Counter field should be added depending on IDoc segments. If the particular segment is repeating 5 times 5 records need to be populated in Internal table.
    Then these 5 records should be mapped to JDBC Table.
    I don't how to handle this situation?
    Pl provide some ideas...
    Regards,
    Rams.

    Hi Mahi,
    Thanks for your reply. If you don't mind do I have your personal mail id so that I will send my requirement to you and help me on this. You can send your mail to my personal mail id: ramesh dot gaddale at gmailcom.
    Regards,
    Rams

  • XML to Internal tables

    Hi,
    Our scenairo is to retreive the data from XML file and convert it into Idoc for inbound processing.
    I need to get the data from xml to the internal tables so that i can convert them to idoc through Function Modules.
    My issue is XML file is not fixed nor the message type and the idoc type. Everything is dynamic.
    I am currently tryin by creating dynamic internal table but i think i need to create multiple dynamic tables from a dynamic table.
    Please suggest the path forward.
    Thanks,
    Varun

    hi,
    check the below code.
    this will convert XML data into an internal table. From this internal table u can manipulate and get desired results.
    *Generated from XML file (upload)
        CALL METHOD xml->import_from_file
          EXPORTING
            filename = p_file
          RECEIVING
            retcode  = ret.
    *convert to string
        CALL METHOD xml->render_2_string
          IMPORTING
            retcode      = ret
            stream       = stream
           size         =
    *convert to xstring
        CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
          EXPORTING
            text   = stream
          IMPORTING
            buffer = xstring
          EXCEPTIONS
            failed = 1
            OTHERS = 2.
        IF sy-subrc  = 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    *Extract data from xsting to internal table
        CALL FUNCTION 'SMUM_XML_PARSE'
          EXPORTING
            xml_input = xstring
          TABLES
            xml_table = it_data
            return    = it_ret.
    Regards,
    Aswin.

  • Reading data from table control in an internal table

    Hello All,
    I want to read the data entered in the screen in an internal table,screen has header segment fields of an idoc and two item segment fields with multiple occurance in form of  two table control,have to read both the table control and have to pass it to idoc inbound function based on postion(posnr) of the order. can anyone provide me with the sample code for the same .
    Thanks and Regards,
    Gunjan

    hi gunjan
    refer to the folllowing code. it will work for u
    Creation of an IDoc generation program
    The following code extract contains everything needed to generate an IDoc from data contained in a table.
    FORM F_110_SEND_IDOC.
    CONSTANTS:
      C_MESTYP TYPE EDIDC-MESTYP VALUE 'ZVISTAPM',"message type
      C_DOCTYP TYPE EDIDC-IDOCTP VALUE 'ZVISTAPM01',"idoc type
      C_SEGNAM TYPE EDIDD-SEGNAM VALUE 'Z1VISTAPM'."segment name
    DATA:
      I_ZVISTA_PM TYPE ZVISTA_PM_T OCCURS 6000,
      I_EDIDC TYPE EDIDC OCCURS 0,
      I_EDIDD TYPE EDIDD OCCURS 0,
      WA_ZVISTA_PM TYPE ZVISTA_PM_T,
      WA_EDIDC TYPE EDIDC,
      WA_EDIDD TYPE EDIDD,
      WA_Z1VISTAPM TYPE Z1VISTAPM,
      V_OCCMAX TYPE IDOCSYN-OCCMAX,
      V_NBSEG TYPE I.
    CLEAR WA_ZVISTA_PM.
    CLEAR WA_EDIDC.
    * Save the message type and the basic IDoc type
    * in the control segment
    MOVE C_MESTYP TO WA_EDIDC-MESTYP.
    MOVE C_DOCTYP TO WA_EDIDC-IDOCTP.
    * Retrieve the maximum number of segments in the basic IDoc
    * type
    SELECT MIN( OCCMAX )
      FROM IDOCSYN
      INTO V_OCCMAX
      WHERE IDOCTYP EQ C_DOCTYP AND SEGTYP EQ C_SEGNAM.
    * Save the whole ZVISTA_PM_T table content
    * in the I_ZVISTA_PM internal table.
    SELECT *
    FROM ZVISTA_PM_T
    INTO CORRESPONDING FIELDS OF TABLE I_ZVISTA_PM.
    * Create a data segment for each line of I_ZVISTA_PM
    LOOP AT I_ZVISTA_PM INTO WA_ZVISTA_PM.
      MOVE-CORRESPONDING WA_ZVISTA_PM TO WA_Z1VISTAPM.
      CLEAR WA_EDIDD.
      MOVE C_SEGNAM TO WA_EDIDD-SEGNAM.
      MOVE WA_Z1VISTAPM TO WA_EDIDD-SDATA.
      APPEND WA_EDIDD TO I_EDIDD.
      CLEAR WA_ZVISTA_PM.
      CLEAR WA_Z1VISTAPM.
    ENDLOOP.
    * Count the number of data segments
    DESCRIBE TABLE I_EDIDD LINES V_NBSEG.
    * If the number of data segments exceeds the maximum
    * allowed number, then edit a message in the spool,
    * then display an error message (quit the program)
    IF V_NBSEG GT V_OCCMAX.
      WRITE:/ TEXT-003, V_OCCMAX.
      MESSAGE E751.
    ENDIF.
    * Call the IDoc creation function
    CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
      EXPORTING
        MASTER_IDOC_CONTROL = WA_EDIDC
      TABLES
        COMMUNICATION_IDOC_CONTROL = I_EDIDC
        MASTER_IDOC_DATA = I_EDIDD
      EXCEPTIONS
        ERROR_IN_IDOC_CONTROL = 1
        ERROR_WRITING_IDOC_STATUS = 2
        ERROR_IN_IDOC_DATA = 3
        SENDING_LOGICAL_SYSTEM_UNKNOWN = 4
        OTHERS = 5.
    * If there was an error, display a message (quit the
    * program)
    IF SY-SUBRC NE 0.
      MESSAGE E746.
    ENDIF.
    ENDFORM.
    regards
    ravish
    <b>plz dont forget to reward points if useful</b>

Maybe you are looking for