Code to populate a zzfield in extract structure

Hi Guru's
I am enhancing a zfield in extract structure for 2lis_13_vditm. I have added the zfield in the append struture & activated it.
Zfield is populated from the table VBAP. I wanted to write an User Exit (EXIT_SAPLRSAP_001) to populate this zfield at CMOD.
As I am not well versed in ABAP,I would really appreciate if you can help me to write a code  to populate this zfield from VBAP.
Thank you,
Neel

Hi,
Check for the sample code for 2LIS_13_VDITM.
For 2LIS_13_VDITM Billing item Data
TYPES: BEGIN OF ty_vbak,
         vbeln TYPE vbeln_va,
         vgbel TYPE vgbel,
       END OF ty_vbak.
DATA: lx_vbak TYPE ty_vbak,
      lt_vbak TYPE TABLE OF ty_vbak.
TYPES: BEGIN OF ty_vbrp,
         vbeln TYPE vbeln_va,
         vgbel TYPE vgbel,
       END OF ty_vbrp.
DATA: lx_vbrp TYPE ty_vbrp,
      lt_vbrp TYPE TABLE OF ty_vbrp.
DATA: lx_billitem TYPE mc13vd0itm.
DATA: lt_billitem TYPE TABLE OF mc13vd0itm .
DATA: lt_billitem_tmp TYPE TABLE OF mc13vd0itm .
For 2LIS_13_VDITM item data
  WHEN '2LIS_13_VDITM'.
    lt_billitem[]  = c_t_data[].
    lt_billitem_tmp[] = c_t_data[].
    IF NOT lt_billitem_tmp[] IS INITIAL.
      SORT lt_billitem_tmp BY aubel.
      DELETE ADJACENT DUPLICATES FROM lt_billitem_tmp COMPARING aubel.
      SELECT vbeln
             vgbel
        FROM vbak
        INTO TABLE lt_vbak
         FOR ALL ENTRIES IN lt_billitem_tmp
       WHERE vbeln = lt_billitem_tmp-aubel
         AND vgtyp = 'G'.
      IF sy-subrc EQ 0.
        SORT lt_vbak BY vbeln.
      ENDIF.
    ENDIF.
Populate the added fields
    LOOP AT lt_billitem INTO lx_billitem.
      l_index = sy-tabix.
      MOVE lx_billitem-vbeln TO l_name.
Internal Text
      CLEAR lt_line.
      REFRESH lt_line.
      CALL FUNCTION 'READ_TEXT'
        EXPORTING
         CLIENT                        = SY-MANDT
          id                            = 'Z010'
          language                      = sy-langu
          name                          = l_name
          object                        = 'VBBK'
        ARCHIVE_HANDLE                = 0
        LOCAL_CAT                     = ' '
      IMPORTING
        HEADER                        =
        TABLES
          lines                         = lt_line
       EXCEPTIONS
         id                            = 1
         language                      = 2
         name                          = 3
         not_found                     = 4
         object                        = 5
         reference_check               = 6
         wrong_access_to_archive       = 7
         OTHERS                        = 8
      IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      IF NOT lt_line[] IS INITIAL.
        CLEAR lx_line.
        READ TABLE lt_line INTO lx_line INDEX 1.
        lx_billitem-zitext = lx_line-tdline.
      ENDIF.
      CLEAR lt_line.
      REFRESH lt_line.
External Text
      CALL FUNCTION 'READ_TEXT'
        EXPORTING
         CLIENT                        = SY-MANDT
          id                            = 'Z011'
          language                      = sy-langu
          name                          = l_name
          object                        = 'VBBK'
        ARCHIVE_HANDLE                = 0
        LOCAL_CAT                     = ' '
      IMPORTING
        HEADER                        =
        TABLES
          lines                         = lt_line
       EXCEPTIONS
         id                            = 1
         language                      = 2
         name                          = 3
         not_found                     = 4
         object                        = 5
         reference_check               = 6
         wrong_access_to_archive       = 7
         OTHERS                        = 8
      IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      IF NOT lt_line[] IS INITIAL.
        CLEAR lx_line.
        READ TABLE lt_line INTO lx_line INDEX 1.
        lx_billitem-zetext = lx_line-tdline.
      ENDIF.
      CLEAR lx_vbak.
      READ TABLE lt_vbak INTO lx_vbak
                 WITH KEY vbeln = lx_billitem-aubel.
      IF sy-subrc EQ 0.
        lx_billitem-zcontract = lx_vbak-vgbel.
      ENDIF.
      IF lx_billitem-aubel EQ lx_billitem-vgbel.
        lx_billitem-vgbel = space.
      ENDIF.
      MODIFY lt_billitem FROM lx_billitem INDEX l_index.
    ENDLOOP.
    CLEAR c_t_data.
    REFRESH c_t_data.
    c_t_data[] = lt_billitem[].
Thanks,
Debasish

Similar Messages

  • Need help in ABAP code to Enhance the Extract Structure ?????

    Hi all,
        I want to enhance the extract structure to get KBETR & KBRUE fields of KONP table since it didn’t allow me to add those fields while creating the generic extractor because of currency key problems. I want to read all KONP records into internal table with KNUMH (Key). Next, I want to fill them into ZZKBETR & ZZKBRUE of Extract Structure ZOXUR40065 in loop.
    DATA:
      i_t_zrebate like ZOXUR40065 occurs 0 with header line,
      reb_tabix like sy-tabix.
    TABLES: KONP.
      Could you please help me in completing the ABAP code?
    Thanks,
    Venkat.

    Hello Manga,
        I have included the following code in ZXRSAU01:
    WHEN 'ZREBATE'.
    PERFORM ZREBATE_EXIT TABLES C_T_DATA.
    After Double click on ZREBATE_EXIT on perform statement, it created ZXRSAF01 include and the following code is added in it:
    FORM ZREBATE_EXIT TABLES FP_C_T_DATA STRUCTURE ZOXUR40065.
    DATA:
    i_t_zrebate like ZOXUR40065 occurs 0 with header line,
    reb_tabix like sy-tabix.
    FIELD-SYMBOLS: <l_c_t_data> TYPE ZOXUR40065.
    LOOP AT fp_c_t_data ASSIGNING <l_c_t_data>.
    reb_tabix = sy-tabix.
    select single KBETR KBRUE
    into (<l_c_t_data>-ZZKBETR,
    <l_c_t_data>-ZZKBRUE,
    from KONP
    where KNUMH eq <l_c_t_data>-KNUMH.
    if sy-subrc eq 0.
    MODIFY fp_c_t_data FROM <l_c_t_data> INDEX reb_tabix.
    endif.
    CLEAR:reb_tabix.
    ENDLOOP.
    ENDFORM.
    When I tried to Activate this ZXRSAF01 include, it fails with 'The FORM "ZREBATE_EXIT" does not exist'.
      Should it be FP_C_T  or P_C_T? I found P_C_T in ZXRSAF01 include.
      What is wrong with it, please ?
       Can't I add this whole code in main include ZXRSAU01itself?
      The Extractor ZREBATE is based on KONA, KONH & KONP tables. This Extractor and KONA table have the same 4000 records and KONP has 13000 records. I want to extract KBERT & KBRUE from KONP.
       Thanks in advance.
    Regards,
    Venkat

  • Problem in populating the new field from the extract structure. Kindly help

    my requirement a new text field is added on R/3 side and I have to populate
    the same field into BW.
    In the R/3 a new customization table 'AAA' is created which will have
    code - char 3 and
    text - char 30.
    The code field is added to a table BBB.
    The SAP standard generic data source exracts data from the table BBB where in the new code field have been added.
    Now I can the see the code field in the extract structure and not in the data source as the filed has selection value 'A' when checked in the ROOSFIELD table.
    To populate the value in BW, I will be creating a Generic Master Data text wherein I fetch the values from the table 'AAA' which the fields code and text  and replicate the same in BW.
    In the reporting level, the code InfoObject will be selected as display both KEY and TeXT, by doing I can populate the values of TEXT in the reporting.
    But to achieve the same I need to add the field code in the ODS but cannot do the same because I am not able to see the field code in the data source.
    Kindly let me know how to achieve the same.
    Also let me know if there is any alternate solution to populate the text field in BW.
    Any Inputs will be appreciated.
    Thanks

    > You should get the userdatasources bound to the
    > columns and assign the values of the recordset to
    > each one and after that use "setLineData" to write in
    > the matrix.
    >
    > hope it helps
    Hi all,
    i have created tables (non BO Tables) directly on the SQL-server and want to use recordset to populate a user form matrix.
    Is there any workaround to achieve this using non BO tables?
    Please provide some sample code since it is a very urgent matter.
    regards
    Daniel

  • Append Structure to MCCOMP but not appear in Extract Structure (LBWE)

    Dear Experts,
    We are using the datasource 2LIS_04_P_COMP
    1) We append a field into MCCOMP and MCCOMPB, but that field doesn't appear in the pool of communication structure fields. Therefore, we cannot move from the pool (right side) to extract structure (left side)
    2) We need to add a field into MCCOMP, as we need to capture Delta for this field. Is there any user exit that can populate value for this structure?

    Hi,
    Follow the steps.
    1. Delete Setup tables in LBWG.
    2. Clear Q in SMQ1/LBWQ.
    3. Delete Q in RSA7.
    Then fine the ECC correct client for Customizing and there you can do the changes and activate it. If still it is not allowing and you want to add fields by using enhancements then goto SE11, and give MCCOMP and Append Structure and add fiels and write code in CMOD.
    Thanks
    Reddy

  • Extract structure

    Hello
    I want to check the program written for the extract structure in R3.Please can someone tell me step by step how to go and view it.And i have the name of my data source.How can i go and find the name of the extractor for it.
    thanks

    Hi  graeme brannen,
    go to -> RSA6 in R/3-> find ur data source
    go to se11 -> ROOSOURCE table -> click on display button -> click on contents button -> give ur data source name -> u will find a field called EXTRACTOR this is the function module name will populates data to ur data source copy that name .
    goto -> SE37 -> paste that function module name -> click on display button -> click on SOURCE CODE TAB.
    this is the code for ur data source.
    assign points if usefull.
    thanks,
    pavan.

  • Change Extract structure -- Access key required ?

    Hi guys,
    I wanted to change the extract structure for one LO extractor. Just add one field from the available pool of fields. Is access key required for this ?
    Thanks,
    BWer

    You can't directly change the extraction structure without an Access Key, nor would you want to. Instead, go to SE11 and pull up the extraction structure you want to modify, in update mode, and then click on the Append Structure... button. You can add the columns of data that you wish to have on the DataSource there. After re-activating the structure, you should then be able to see the columns that you added in the maintenance view for the DataSource, pull them over, re-generate the DataSource and create the code in CMOD to populate these columns.

  • Code to populate fields

    Hi gurus,
    I have 2 Z-fields in VBRP table.I have appended these fields to  the extract structure(2LIS_13_VDITM).I need to write a code to populate these fields with Data.As i am new to ABAP,can anyone help me with the code.Very much appreciated,also it would be great if you could just write in comments for what each line of code does.
    Thanks in advance

    Hi ,
          This is just a sample,
    TABLES: vbak,
            ekkn,
            vbap,
            ekpo.
    DATA: o_ekko LIKE ekko,
          i_t_ekpo LIKE ekpo   OCCURS 1 WITH HEADER LINE.
    DATA: BEGIN OF lt_custmat OCCURS 0,
                 kunnr LIKE vbak-kunnr,
                 matnr LIKE vbap-matnr,
          END OF lt_custmat.
    DATA: ld_distributionfactor LIKE mcekpo-abcposo,
          ebeln LIKE ekpo-ebeln,
          ebelp LIKE ekpo-ebelp,
          it_ekpo TYPE TABLE OF ekpo WITH HEADER LINE,
          old_val(50) TYPE c.               "For storing the value from the                            
                 style='mso-tab-count:3'>                                          "Field Symbol
    FIELD-SYMBOLS <fs> TYPE ANY TABLE.
    CASE zeitp.
      WHEN 'MA'.                            "When creating a purchase order
        MOVE '(SAPLEINS)T_EKPO[]' TO old_val.
        ASSIGN (old_val) TO <fs>.
        i_t_ekpo[] = <fs>.
        LOOP AT xmcekpo.
          ebeln = xmcekpo-ebeln.
          ebelp = xmcekpo-ebelp.
          IF xmcekpo-supkz = '1'.            "Old Value ?
            SELECT SINGLE * FROM ekpo INTO it_ekpo WHERE ebeln = ebeln AND
         ebelp = ebelp.
            xmcekpo-zkopprctr = it_ekpo-kopprctr.
          ELSE.                              "New Value ?
            READ TABLE i_t_ekpo WITH KEY ebeln = ebeln
                                         ebelp = ebelp.
            xmcekpo-zkopprctr = i_t_ekpo-kopprctr.
          ENDIF.
          MODIFY xmcekpo .
        ENDLOOP.
    hope it helps,

  • Enchancing R/3 Extract Structure 2LIS_13_VDITM

    Hi,
    I would like to add an custom field in the Extract Structure 2LIS_13_VDITM.
    Could anyone please tell me the steps to do so?
    Thanks in advance.
    Best Regards,
    Chris

    Hi,
    1) Go to Rsa6 and select the DS 2LIS_13_VDITM , and double click on it and note down the  ES name .It is
    2) Go to Se11 and keep the ES name at DATATYPE and clcik on Display. and then Click on Append structure Button.
    3) Give the techinica name to AS in the immedaite screen and then give description in other screen and enter the zzfields that you want to add. Finally activate the Append Structure.
    4) aggin goto RSA6 and enter into change mode for the DS 2LIS_13_VDITM , and then remove tick mark for newly added fields aginst <i>Hide only</i> .
    5) Replicate the DS into BIW.
    6) give th ccoding for these newly added fields in CMOD.
    7) in CMOD , you need to use already existing project. If there is no project existing,then create new one . While creating take RSAP0001 as Enhance ment assignement.
    8) you have to code the ABAP lines in EXIT_SAPLRSAP_001 component and in the include ZXRSAU01.
    9) Donot forget the activation of Project and include after every  modifications.
    With rgds,
    Anil Kumar Sharma .P

  • Enhancing Extract Structure (MC11VA0HDR)

    Hi BI Experts,
    I have added user-defined fields (beginnig with Z) to extract structure (Sales Order Header - MC11VA0HDR) to be the same name as in the base table and communication structure. The Z fields were added in the sales document table (VBAK) using an append and are also available in the communication structure. After generating extract structure, I then log on to TX LBWE and generated datasource and replicated in BI. When I tested it in TX RSA3, these user-defined fields are blank even though they are populated in base table (VBAK). Could you please help me what steps I need to follow in order to populate them?
    Thanks for your help.

    Hello,
    The values from custom appended field will not get populated automatically.
    You will have to write a code in CMOD and in the exits to populate these custom field values.
    There are lot of documents in the forum along with sample code which tells you how to write the code in CMOD.
    see this blog on how to do it.its for customer data source.
    same can be done for LO data source.
    https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b0af763b-066e-2910-a784-dc6731660f46
    Regards
    Ajeet

  • Enhancing the extract structure of Datasource 0CO_OM_CCA_9

    Hi,
       My requirement goes as, we have a cube already getting populated with the data of 0CO_OM_CCA_9.
    Now I have a accounting doc. available. My issue is we need a corresponding COPA doc.and its customer and produt for this accounting doc.
    My Functional guy says, we can get the corresponding copadoc. and its details from the table CE10010. So now I need to add to fields to my stnd. extract structure and populate these 2. I know how to add them to the structure. My issue is all about populating them.
    I see in RSA2 , that the extractor is a FM, which provides no exit within .
    As far as my knowledge goes, is it sufficient if I write some code in the CMOD to fetch data from CE10010 and then pass it on to the extract structure, or do we have any thing else to be done to populate them.
    Thanks in advance,
    Sudha

    Hi
    Enhancing Extract structure can be achieved through the coding (cmod).
    Or else you can even go for the Generic Data Source to combine both the tables.
    Hope it helps

  • Enhancing Extract structure for 2LIA_13_VDITM

    Hi all,
    I have requirement to enhance my billing cube with tax details. At present we have report lik below...
    Sales Org     Comp Cd     Plant     Cntry     Sold-to party     Name 1     Street     City      Region (State)     Postal Code     Country     Ship-to party     Name 1     Street     City      Region (State)     Postal Code     Cntry     Billing type     Doc. cat. Q/O/D/I     Billing Document     Material     Material Description     Country of Origin fo     Ref Delivery Number     Sales document     Doc cur     Calendar     Month     Billed Quantity     Cost     Net value
    In addition with above we need
    Conversion Rate     Tax XR1 GST 5%     Tax XR2 HST/QST     Tax XR3 PST
    So I want to add above 4 fields for my extract structure MC13VD0ITM.  Can any one help be in respect of CMOD coding and append structure?

    Hi ,
    Are the fields present in the structure of the Data source and not there or you want to populate the fields from different tables?
    double click on the extract sructure --> click on append structure --> it will prompt for Append struture name --> enter and click ok -->add the fileds to the append and activate the structure.
    next in implement the logic in CMOD....
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0af763b-066e-2910-a784-dc6731660f46
    Regards
    KP

  • Enhancing extract structure

    Hi all.,
           How will you enhance the extract structure, which is already in the production system without affecting the delta? Can anyone help me.
    Thanks
    Sangeetha

    Hi Sangeetha
    You should do all development related to this enhancement in Dev System and then do testing in QA system and then transport these to Production system.
    For enhancement of extract structure and it's deployment in production system without affecting the delta, Please read my weblog on same subject titled as "How to retain deltas when you change LO extractor in Production system
    " and the link is /people/pradip.patil/blog/2006/06/07/how-to-retain-deltas-when-you-change-lo-extractor-in-production-system
    How to enhance the extract structure-
    <u>If your data source in Non-LO cockpit</u>
    1. Go to RSA6, click on data source and go to extract structure.
    2. In extract structure maintenance you will find Append structure button on upper right corner, click on that.
    3. Name the new append structure, insert required fields.
    4. Activate the structure & also activate the extract structure.
    5. In LBWE go to datasource maintenance and uncheck the Hide check box for newly added fields and Save the data source.
    6. Write code in user exit in CMOD to populate newly added fields.
    <u>If your datasource is LO cockpit datasource</u>
    <u>Option 1- Enhance in LBWE</u>
    1. check in LBWE- Maintenance -> check if your required field is available in pool (right hand side).
    2. If it is available then send it to left hand side.
    3. Save and you will find the new field as part of your extract structure.
    4. In LBWE go to datasource maintenance and uncheck the Hide check box for newly added fields and Save the data source.
    5. No need to write user exit code for these fields.
    <u>Option 2- Append & user exit code</u>
    If your required field is not available in LBWE Manitainance then follow all steps given above in "If your data source in Non-LO cockpit".
    Regards
    Pradip

  • Can I enhance extract structure with standard field?

    Friends,
    Can I enhance the extract structure with standard field.
    Eg. If I want add(append) field PACKNO to Extraction structure MCVGIH. PACKNO is a field from standard table. So Can I do this and populate this without using abap code(customer exit) Should I give foreign key field also in the append stucture.
    Please help me
    Joe

    Hi Joe,
    mostly it works as A.H.P explained, because in the extractor they mostly do a move-corresponding of the fields. Sometimes they don't, specially for newer applications and extractors because the abap statement move-corresponding is on the list of obsolete statements. In that case you need to do some coding.
    So basically I would recommend to add the field, regenerate the datasource and check the result with rsa3.
    regards
    Siggi
    Message was edited by: Siegfried Szameitat

  • Extract Structure Enhancement

    Hi All,
    We need to enhance the std SD extraction structure with few fields. Now for some fields already base table of 2LIS_11_VA* i.e VBAK/VBAP are enhanced and same fields i need to use in 2LIS_11_VA*. So do i need to write exit code for these fields????

    Hi,
    You have to enhance your extract sturcture by
      appending the extract structure along with other activities.
    Append the extract structure with required fields
    Enable the fields for display in the transfer structure (this will come when u save the DSafter appendings)
    Write code in the exit to populate the newly
    go to CMOD t-code check which all methods are there...and you have to find the one which is used to enhance the data sources for BW.
    Hope this helps you ..
    Regards,
    Shikha

  • Extract Structure Help

    Hi All,
    When I look for fields for my Extract structure , I can see some field are in blue color and some are in black , It must be having some meaning , I dont know that , Can you please let me know what is that mean ?
    and one more thing what is diffrance betweent adding append stucture and Enhansment done in Data source ?
    What is relation between Append stucture and Enhansment  ? Do we need to right extraction logic for appended feilds ?
    Please help me to understand this
    Regards
    Ashutosh D

    Hi
    The Black are the direct fields in the strcture and the blue came through the include structure and append structure. The includes are used by sap for the reusability purpose.
    Enhancement includes appending the extract structure along with other activities.
    Append the extract structure with required fields
    Enable the fields for display in the transfer structure (this will come when u save the DSafter   appendings)
    Write code in the exit to populate the newly added fields.
    Hope this will help you!!

Maybe you are looking for

  • Making a pdf book

    Hi all, Hopefully someone can help me out with this.. I would like to make an ebook/PDF book (i'm not sure what the difference is!!!?) I don't have a clue how to go about this. I'm a musician and I have all my lyrics and chords all neatly displayed i

  • CF11 : cflogin doesn't "stuck" after session/login timeout

    Hi, Since migrating from CFMX7 to CF11 we are experiencing some weird failure with cflogin (using session or cookie storage). Basically when we log-in on the application after a session/client timeout the first login doesn't last for longer than the

  • How can I get the File Creation Date OR Last modification date of the incoming file in my message?

    I need the Last Modification Date and the File creation date of the consumed file in my message, is it possible to do that using a custom pipeline component in decode stage or any other way? The FILE namespace have File creation time that actually gi

  • Best approach for copying DB from one system to another

    I have Oracle 9i Enterprise running on a UNIX box with a large database upon it (well, 3 - 2 test databases). I want to recreate one of the databases in Personal Oracle on a Windows machine, again 9i. I have managed to export the database into DMP fi

  • Remove white border around TOC

    Hello all, I have set a black background to the HTML page, playback controls and TOC. Yet Captivate draws a white border line 1px wide around the TOC. Is there any way to remove this?