Skip to Content
author's profile photo Former Member
Former Member

Transformation ABAP Statement to create Duplicate records

Hi,

I am planning to load Employee and respective sales orgs to a Z Info Object(User ID compounded on Seq No) from a flat file.

Source Data Will be like below


SEQ NO
USER_ID
SALES_ORG 1 10000167 411 2 10000167 473 3 10000167 1068 4 10000169

*

5 10000200 * 6 10000289 501 7 10000289 513 8 10000289 514 9 10000289 513B 10 10000289 513C 11 10000289 513D

My requirement is to write a routine in transformation where for Users with * (Ex:10000169),It should create multiple entries with full list of sales org from 0SALESORG master data.


In Start routine 0SALESORG master data is selected and saved in Internal Table IT_SAL_ORG

Please advise how to create multiple entries

Thanks in advance

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on May 21, 2015 at 11:09 AM

    Hi,

    Try to use Rule Group functionality in transformations. Google with "Rule Groups in Transformation" you will some good documents on how to achieve this.

    Also go through the below link.

    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c07161ee-afa6-2c10-06bd-f1c8643558a5?QuickLink=index&…

    Regards,

    Vengal.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 21, 2015 at 03:59 PM

    Hi !

    Try with this routine.

    SELECT SALESORG

    FROM /BI0/PSALESORG

    INTO TABLE IT_SALESORG

    WHERE SALESORG <> '' AND

    OBJVERS = 'A'.

    IT_SOURCE[] = SOURCE_PACKAGE[]

    LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields>.

    IF <source_fields>-salesorg = '*'.

    LV_SEQNO =<source_fields>-seqno.

    LV_USERID =<source_fields>-userid.

    LOOP AT it_salesorg INTO wa_salesorg.

    wa_source-seqno = LV_SEQNO

    wa_source-userid = LV_USERID

    wa_source-salesorg = wa_salesorg-salesorg

    APPEND IT_SOURCE.

    ENDLOOP.

    ENDIF.

    ENDLOOP.

    SOURCE_PACKAGE[] = IT_SOURCE[]

    Regards.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 22, 2015 at 09:13 AM

    Hi SAP USER,

    I am sure if I am late in answering to your query but I propose the following :

    TYPES: BEGIN OF ty_salesorg,

    salesorg TYPE /bi0/oisalesorg ,

    objvers TYPE rsobjvers,

    END OF ty_salesorg.

    DATA : it_salesorg TYPE TABLE OF ty_salesorg,

    wa_salesorg TYPE ty_salesorg,

    t_source TYPE STANDARD TABLE OF _ty_s_sc_1,

    gs_source TYPE _ty_s_sc_1,

    gs_result TYPE _ty_s_tg_1,

    lv_sequence TYPE i.

    REFRESH : it_salesorg, result_package.

    CLEAR : lv_sequence.

    SELECT salesorg objvers

    FROM /bi0/psalesorg

    INTO TABLE it_salesorg

    WHERE salesorg <> space

    AND objvers = 'A'.

    IF sy-subrc = 0.

    SORT it_salesorg BY salesorg objvers.

    DELETE ADJACENT DUPLICATES FROM it_salesorg.

    ENDIF.

    t_source[] = source_package[]. " Transfer Original Values

    LOOP AT source_package INTO gs_source.

    IF gs_source-salesorg <> '*'.

    lv_sequence = lv_sequence + 1.

    gs_result-/bic/zsoruser = gs_source-/bic/zsoruser. "User ID

    gs_result-salesorg = gs_source-salesorg. "Sales_Org

    gs_result-/bic/zcounter = lv_sequence. "SEQ No

    APPEND gs_result TO result_package.

    ELSEIF gs_source-salesorg = '*'.

    LOOP AT it_salesorg INTO wa_salesorg. " Case for multiple entries in case of *

    lv_sequence = lv_sequence + 1.

    gs_result-/bic/zsoruser = gs_source-/bic/zsoruser. "User ID

    gs_result-salesorg = wa_salesorg-salesorg. "Sales_Org

    gs_result-/bic/zcounter = lv_sequence. "SEQ No

    APPEND gs_result TO result_package.

    ENDLOOP.

    ENDIF.

    ENDLOOP.

    " result_package contains final values.


    Hope you find some use for the above. 😊


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.