Synchronizing Two Custom Z Tables Using Abap Program

Hi,
    My requirement is Synchronizing two custom z tables using abap program me.
I have vendors in two tables, i have to select the common vendors from first which are existing in second  table also.
In first table each vendor can have more than one supplier types in one field only. In second table these supplier types are divided into
different fields.
     My requirement is I have to check supplier types in first table and i have to pass X to corresponding supplier types in second table vendor.
I have to pass X value for each depending in Second table depending upon supplier type in first table.
. How to do it can any one suggest with code.
Thanks in Advance,
Vivek
<subject edited by moderator>
Message was edited by: Manish Kumar

Hi,
Imho, you need to get (meaning, extract into separate fields) the different supplier types from Table1 first. Your key for Table1 is the vendor no, which is also the key in Table2 (or the key for Table2 is Vendor no & Type).
For better performance, better select multiple/all required entries from Table1 instead of doing a select endselect.
Depending on the format of the vendortypes in Table1, put them in a new itab (for our purpose named Table1New where vendor no & type are the only 2 fields. For example, if the type length is fixed to 2 chars, or divided by space,... use your coding accordingly.
Next step is to select all vendor no's in Table2 which you have selected in Table1. If in Table2, the vendor no is the only key (and the all vendor types are filled in a single record), then loop check the vendor types from Table1New against the types in Table2.
If the key of Table2 is vendor no & vendor type, then do a read table for the key.
The logic in pseudo-code:
Select from Table1 into table. If you'd like to limit the selection size, add package size statement.
     extract the vendor types in to itab Table1New.
     Select the vendor & types from Table2 by using the for all entries option (better performance).
     loop at Table1New
          check in Table2:
               if the unique key is vendor no: check all fields for the vendor type from Table1New
               if the unique key combo is vendor no & type: check by using a read table.
          If not found => add entry to Table2
     endloop.
endselect Table1 (when using package size)
I guess the most difficult step is to extract the types from Table1 into separate fields, all the rest seems straight forward. Please keep in mind the itab type definitions for a better performance.
Good luck!
Best regards,
Zhou

Similar Messages

  • Access table using ABAP program in other database

    Dear SAP Expert,
    We have requirement that related to SAP interface.
    Our SAP system run on Oracle database 11g (Unix).
    Illustration: SAP system = A non SAP system = B
    We need to access a table using ABAP program (from SAP system A) in other database (system B) that are not necessarily SAP database. The non-SAP system using SQL Server 2008 (Windows).
    What is the best practice for this interface
    Do we need database link? If yes, please help to inform me the details step to configure it.
    Thanks and Regards

    Hi Friend,
    You try using an intermediate system..passing your input required to fetch the data..and PI should call the respective query to retrive record..once the full flow is completed you should get the return through some table in the calling program.
    else.
    ask the other system guy to write a function with select query and ask him to expose as RFC and that RFC we have to call it as RFC in our program to get the required values and only thing we need here is a proper connector in place.
    Regards
    S.Janagar

  • Custom Objects List Using ABAP Program

    Hi Experts,
    We have  a requirement to collect all the custom objects(reports,smartforms,ddic objects etc)developed in ECC.
    We need list basing on condition of 'last changed by' .
    So for few objects we have 'last changed by' field and we are able to get the list but for few custom objects 'last changed by' field is not maintained.
    Example for BTE there is no 'last changed by'...
    Please suggest if any ideas.
    Regards,
    Rafi

    Hi Rafi,
    Do a source scan using RS_ABAP_SOURCE_SCAN for reports..Put Z* and give your respective conditions on last change field.
    2.Check the Transport list to production you will get other details.
    Hope it will be helpful for you.
    Regards,
    Kannan

  • How to transfer data in change log table of dso to z-table using abap code

    Hi  can you please explain me how to transfer data in change log table of dso to z-table using abap code ,with out using Function module concept

    PROGRAM NAME:   ZBW_DELTA_TO_GSTAR                                 **
    report ZBW_DELTA_TO_GSTAR no standard page heading
                                     line-size 120
                                     line-count 75
                                     message-id ZBW_MSG_CLS.
    tables:   ZGIV_DLTA_EBV_BB,
              ZGIV_DLTA_EM2_BL,
              ZGIV_DLTA_EM2_BK.
    Selection Screen Definitions
    SELECTION-SCREEN: BEGIN OF BLOCK INNER WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN: SKIP 1.
    PARAMETERS:       EBVBB RADIOBUTTON GROUP ROLL,
                      EM2BL RADIOBUTTON GROUP ROLL,
                      EM2BK RADIOBUTTON GROUP ROLL.
    SELECTION-SCREEN: END OF BLOCK INNER.
    Data:  WS_UPDATE_FLAG  Type C,
           UCounter(9)      Type N,
           ICounter(9)      Type N.
    DATA:  T_ZGIV_DLTA_EBV_BB Type Standard Table of ZGIV_DLTA_EBV_BB,
           s_ZGIV_DLTA_EBV_BB LIKE line of T_ZGIV_DLTA_EBV_BB.
    DATA:  T_ZGIV_DLTA_EM2_BK Type Standard Table of ZGIV_DLTA_EM2_BK,
           s_ZGIV_DLTA_EM2_BK LIKE line of T_ZGIV_DLTA_EM2_BK.
    DATA:  T_ZGIV_DLTA_EM2_BL Type Standard Table of ZGIV_DLTA_EM2_BL,
           s_ZGIV_DLTA_EM2_BL LIKE line of T_ZGIV_DLTA_EM2_BL.
    Standard Internal Tables - Describe usage.
    data: begin of i_AEPSD_O0140 occurs 0.
            include structure /BIC/AEPSD_O0140.
    data: end of i_AEPSD_O0140.
    data: begin of i_AEPSD_O0240 occurs 0.
            include structure /BIC/AEPSD_O0240.
    data: end of i_AEPSD_O0240.
    data: begin of i_AEPSD_O0340 occurs 0.
            include structure /BIC/AEPSD_O0340.
    data: end of i_AEPSD_O0340.
    data: begin of i_GIV_DLTA_EBV_BB occurs 0.
            include structure ZGIV_DLTA_EBV_BB.
    data: end of i_GIV_DLTA_EBV_BB.
    data: begin of i_GIV_DLTA_EM2_BK occurs 0.
            include structure ZGIV_DLTA_EM2_BK.
    data: end of i_GIV_DLTA_EM2_BK.
    data: begin of i_GIV_DLTA_EM2_BL occurs 0.
            include structure ZGIV_DLTA_EM2_BL.
    data: end of i_GIV_DLTA_EM2_BL.
    Miscellaneous Program Variables and Constants.
    TOP-OF-PAGE
    top-of-page.
    START-OF-SELECTION
    start-of-selection.
      Clear: i_GIV_DLTA_EBV_BB,
             i_GIV_DLTA_EM2_BK,
             i_GIV_DLTA_EM2_BL,
             UCounter, ICounter.
      IF EBVBB = 'X'.
        PERFORM 100_EXTRACT_EBV_BB_DELTA_RECS.
      ELSEIF EM2BK = 'X'.
        PERFORM 100_EXTRACT_EM2_BK_DELTA_RECS.
      ELSE.
        PERFORM 100_EXTRACT_EM2_BL_DELTA_RECS.
      ENDIF.
    FORM 100_EXTRACT_EBV_BB_DELTA_RECS
    FORM 100_EXTRACT_EBV_BB_DELTA_RECS.
      Refresh:   i_AEPSD_O0140,
                 i_GIV_DLTA_EBV_BB.
      Clear:      UCounter, ICounter, s_ZGIV_DLTA_EBV_BB .
      Select * From /BIC/AEPSD_O0140
        Into TABLE i_AEPSD_O0140.
      IF SY-Subrc = 0.
        LOOP AT i_AEPSD_O0140.
          MOVE-CORRESPONDING i_AEPSD_O0140 TO s_ZGIV_DLTA_EBV_BB.
          MOVE SY-DATUM to s_ZGIV_DLTA_EBV_BB-create_dt.
          INSERT ZGIV_DLTA_EBV_BB FROM s_ZGIV_DLTA_EBV_BB.
          IF SY-Subrc = 0.
            ICounter = ICounter + 1.
          ELSE.
            UPDATE ZGIV_DLTA_EBV_BB FROM  s_ZGIV_DLTA_EBV_BB.
            IF SY-Subrc = 0.
              UCounter = UCounter + 1.
            ELSE.
              Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    "100_EXTRACT_EBV_BB_DELTA_RECS
    FORM 100_EXTRACT_EM2_BK_DELTA_RECS
    FORM 100_EXTRACT_EM2_BK_DELTA_RECS.
    Refresh:   i_AEPSD_O0240,
               i_GIV_DLTA_EM2_BK.
      Clear:      UCounter, ICounter, s_ZGIV_DLTA_EM2_BK .
      Select * From /BIC/AEPSD_O0240
        Into TABLE i_AEPSD_O0240.
      IF SY-Subrc = 0.
        LOOP AT i_AEPSD_O0240.
          MOVE-CORRESPONDING i_AEPSD_O0240 TO s_ZGIV_DLTA_EM2_BK.
          MOVE SY-DATUM to s_ZGIV_DLTA_EM2_BK-create_dt.
            INSERT ZGIV_DLTA_EM2_BK FROM s_ZGIV_DLTA_EM2_BK.
          IF SY-Subrc = 0.
            ICounter = ICounter + 1.
          ELSE.
            UPDATE ZGIV_DLTA_EM2_BK FROM  s_ZGIV_DLTA_EM2_BK.
            IF SY-Subrc = 0.
              UCounter = UCounter + 1.
            ELSE.
              Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    "100_EXTRACT_EM2_BK_DELTA_RECS
    FORM 100_EXTRACT_EM2_BL_DELTA_RECS
    FORM 100_EXTRACT_EM2_BL_DELTA_RECS.
    Refresh:   i_AEPSD_O0340,
               i_GIV_DLTA_EM2_BL.
      Clear:      UCounter, ICounter, s_ZGIV_DLTA_EM2_BL .
      Select * From /BIC/AEPSD_O0340
        Into TABLE i_AEPSD_O0340.
      IF SY-Subrc = 0.
        LOOP AT i_AEPSD_O0340.
          MOVE-CORRESPONDING i_AEPSD_O0340 TO s_ZGIV_DLTA_EM2_BL.
          MOVE SY-DATUM to s_ZGIV_DLTA_EM2_BL-create_dt.
            INSERT ZGIV_DLTA_EM2_BL FROM s_ZGIV_DLTA_EM2_BL.
          IF SY-Subrc = 0.
            ICounter = ICounter + 1.
          ELSE.
            UPDATE ZGIV_DLTA_EM2_BL FROM  s_ZGIV_DLTA_EM2_BL.
            IF SY-Subrc = 0.
              UCounter = UCounter + 1.
            ELSE.
              Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    "100_EXTRACT_EM2_BL_DELTA_RECS
    END-OF-SELECTION
    end-of-selection.
      perform D1000_REPORT_DATA.
    D1000_REPORT_DATA
    form D1000_REPORT_DATA.
    *Display the title of the program
      write: /25 SY-TITLE.
      skip.
    Diaplay the details of the user and time
      write: /1 'Executed by', 15 SY-UNAME, 30 'Date',
      38 SY-DATUM, 53 'Time', 60 SY-UZEIT.
      skip 2.
      write: /  'Delta Records have been extracted  ',
             /   'Updates : ', UCounter,
             /   'Inserts : ', ICounter.
      skip.
      skip 3.
      write: /20 'End of the report'.
    endform.                                           "D1000_REPORT_DATA
    chgeck it out this also may hep you

  • Fork in process chain using ABAP program

    Hello everyone.
    I need a fork in my chain. Depending on the values in some db table I will make a decision: do some process or skip and go further. The only solution I can see is using ABAP program. But unfortunately It doesn't return status. Any suggestion will be appreciated.

    Hi,
    You have few process to run after the abap program. So make all those process as a different chain, and at the end of the ABAP program include a function module to trigger this chain, based on your condition.
    If you like this idea, please revert for more information.
    Hope this helps.
    Thank you,

  • Unzip files using ABAP program

    Hi All,
    Can anybody guide me how to Unzip a .zip file using ABAP program... Appreciate your immediate reply...
    actually, my scenario is to check whether zip file is created in appl.server or not.., and if zip file created then i need to check whether its blank file or any content exist inside the file...
    Thanks in advance
    Bhasker

    hi
    good
    parameters: command(236) lower case.
    data: std_lines(255) occurs 0 with header line.
      call function 'RFC_REMOTE_PIPE'
        destination 'SERVER_EXEC'
        exporting
          command = command
          read = 'X'
        tables
          pipedata = std_lines
        exceptions
          communication_failure = 1
          system_failure = 2.
    You should put your Unix command in the command parameter. "gunzip /yourfilepath/yourfilename" works on my Unix system. Once you determine the proper Unix command, you should be set. This technique is also nice because it provides you with echos back from Unix in table std_lines. For more complex Unix activity, you may want to consider throwing together a Unix script, and calling that via this code.
    reward point if helpful.
    thanks
    mrutyun^

  • How to print external file using ABAP program

    Hello
    I want to print an external file which is located in server (
    20.99.0.18\GUI\xyz\8.0QUALITY\QM_TS.DOC) .....i want to print these kind of files(which i have retrieved from table 'DRAW' field 'filep' )......i need to print these files using ABAP program.
    thank you
    Vikram.
    Message was edited by:
            Vikram Bojja

    extract the data and pass to script or smartform for printing

  • HOW TO creat  BAR CHART using ABAP Programming

    DEAR ALL,
    I want some help as to how to creat GRAPHICAL display using ABAP programing (BAR CHART) any sample codes Example will be very helpful.
    Regards,
    VJ

    On earlier versions, you can do something like this.
    [code]
    REPORT ZRICH_0005 .
    DATA: BEGIN OF ITAB_DATA OCCURS 0,
               DATANAME(15),
               QUANTITY1 TYPE I,
               QUANTITY2 TYPE I,
               QUANTITY3 TYPE I,
          END OF ITAB_DATA.
    Data: BEGIN OF ITAB_OPTIONS OCCURS 0,
               OPTION(20),
          END OF ITAB_OPTIONS.
    ITAB_DATA-DATANAME = 'Maple'.
    ITAB_DATA-QUANTITY1 = 5500.
    ITAB_DATA-QUANTITY2 = 6200.
    ITAB_DATA-QUANTITY3 = 5900.
    APPEND ITAB_DATA.
    ITAB_DATA-DATANAME = 'Oak'.
    ITAB_DATA-QUANTITY1 = 3500.
    ITAB_DATA-QUANTITY2 = 5200.
    ITAB_DATA-QUANTITY3 = 4400.
    APPEND ITAB_DATA.
    ITAB_DATA-DATANAME = 'Cherry'.
    ITAB_DATA-QUANTITY1 = 1800.
    ITAB_DATA-QUANTITY2 = 2200.
    ITAB_DATA-QUANTITY3 = 1900.
    APPEND ITAB_DATA.
    CALL FUNCTION 'GRAPH_MATRIX_3D'
         EXPORTING
              COL1        = 'Jan'
              COL2        = 'Feb'
              COL3        = 'Mar'
              TITL        = 'Lumber Usage in $'
         TABLES
              DATA        = ITAB_DATA
              OPTS        = ITAB_OPTIONS
         EXCEPTIONS
              OTHERS      = 1.
    [/code]
    Regards,
    Rich Heilman

  • Urgent!!  How to call a custom transaction or an ABAP program in BSP?

    Urgent!!  How to call a custom transaction or an ABAP program in BSP?
    We are pretty new on BSP.  Would be very appreciated if any expert here give us the detailed steps on how to build up the application to just call a custom transaction (e.g., t-code: ztest) or an ABAP program.  Would we have to create a button or event handler to do that?  And the detailed steps?
    Thanks in advance and we will definately give you reward points!

    hi Durairaj,
    During the time to wait for your answer, we copied Bernd's code from your last link, but when activating it, get the 1st error msg:
    Field "CLIENT" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement. "DATA" statement."DATA" statement. The error shows up here:
    <td>
    <htmlb:inputField id = "client"
    value = "<%= client %>" />
    </td>
    Then we added Client to the page attribute and define it as type String, then get another error:
    The field "EVENT" is unknown, but there is a field with the similar name "EVENT_ID"."EVENT_ID". This error shows up at the beginning in the Event Handler:
    OnInputProcessing:
    code
    • event handler for checking and processing user input and
    • for defining navigation
    • event handler for data retrieval
    event = cl_htmlb_manager=>get_event( runtime->server->request ).
    IF event->name = 'button' AND event->event_type = 'click'.
    button_event ?= event.
    How to resolve this unknown Event error, need to define in Page Attribute tab? but with what type?
    Actually we only want to run an ABAP4 program in BSP, the code is complicated, could you show us an easy way of doing this in BSP?

  • Macro format to use ABAP Program

    Hi,
    I need to run an abap program based on certain condition and that is if the user selection is at particular level say at "Customer" level then that abap program should run else don't do anything and exit.
    If "DetLevel" = customer then
    ABAP program
    else
    exit
    end if.
    I am not able to put this in correct way it seems because if I am not at correct level then also the abap program is run.
    Please help me to understand the way to achieve this.
    Thanks,
    Pankaj

    Hi Awa,
    It's regarding your questions..
    Yes you can make it ..
    You can create your data source program in your source system such as R/3, CRM, etc.
    There is template function that can be used for your program:
    RSAX_BIW_GET_DATA_SIMPLE.
    You can use that template, and alter the code as your business requirement.
    There are also blog, and tutorial as your references:
    Generic Extraction via Function Module
    http://help.sap.com/saphelp_nw04/helpdata/en/3f/548c9ec754ee4d90188a4f108e0121/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/86/1c8c3e94243446e10000000a114084/frameset.htm
    Hopefully it can help you a lot.
    Regards,
    Niel.

  • Accessing Oracle Tables using ABAP

    Dear All,
    We are using SAP ECC 6.0, we need to access some of the tables in oracle system using ABAP program. Is there any wany to access the oracle tables.
    Please suggest and do the needful.
    Thanks in advance,
    Chandra

    DECLARE YOUR ORACLE INSTANCE INTO TABLE DBCON
    AND USE THE FOLLOWING FM TO ACCESS YOUR DATA
    RSDBC_DB_DATA_GET
    RSDBC_DB_DSOURCE_CHECK
    RSDBC_DB_DSOURCE_CONVERT
    RSDBC_DB_DSOURCE_GENERATE
    RSDBC_DB_FIELDS_CHECKS
    RSDBC_DB_FIELDS_GET
    RSDBC_DB_SCHEMAS_GET
    RSDBC_DB_TABLES_GET
    RSDL_CONNECTION_CHECK
    RSDL_DB_GET_ALL_TABLES
    RSDL_DB_GET_DATA
    RSDL_DB_GET_DATA_BWS
    RSDL_DB_RFC_GET
    RSDL_TRACEFILE_DISPLAY
    RSDS_ACCESS_DB_DATA_UPLOAD
    RSDS_ACCESS_DB_DATA_UPLOAD_2
    RSDS_ACCESS_DB_FIELDS_GET
    RSDS_ACCESS_DB_TABLES_GET
    OR WRITE YOUR OWN CODE USING THIS OBJECTS
    cl_sql_connection
    cl_sql_statement
    cl_sql_result_set

  • Update MS Access Database table using ABAP

    Hi All,
    I have a requirement wherein I have to update the existing records in MS Access database using ABAP Code. Can someone provide sample code through which I can achieve this. Thanks!!!
    Regards,
    Nitish Reddy.
    Edited by: Nitish Cherukupally on Mar 30, 2009 4:02 PM

    hi,
    please refer to this link
    http://learningabap.wordpress.com/2007/04/11/get-data-from-ms-access-into-internal-table/
    http://abapcode.blogspot.com/2007/05/get-data-from-ms-access-into-internal.html
    http://abapcode.blogspot.com/2007/06/sample-program-to-upload-excel-document.html
    MS Access Database using ABAP Program
    thanks

  • Is it possible to reset password for any user using abap program

    Hi friends,
    Is it possible to reset password for any user using abap program by specifying client number and user id. in selection screen.
    if any code for that to reset password please mail me.
    Thanks & Regards,
    Yogesh

    Hello Yogesh,
    Yes you can reset the password for any body using ABAP Code. But for that you really don't need any client number.
    If this process is on regular basis, then recommended is to use BAPI for changing the user details Otherwise BDC also works fine.
    => Function Module - BAPI_USER_CHANGE
    Call this in the program for resetting the password.
    => CALL TRANSACTION 'SU01' USING InternalTable
    This will be executed in the BDC of SU01 transaction recording. Use the Password Change button in the application toolbar of transaction while recording.
    Hope this helps.
    PS If the answer solves your query, plz close the thread by marking it solved and rewarding each reply.
    Regards

  • How to extract data from info cube into an internal table using ABAP code

    HI
    Can Anyone plz suggest me
    How to extract data from info cube into an internal table using ABAP code like BAPI's or function modules.
    Thankx in advance
    regds
    AJAY

    HI Dinesh,
    Thankq for ur reply
    but i ahve already tried to use the function module.
    When I try to Use the function module RSDRI_INFOPOV_READ
    I get an information message "ERROR GENERATION TEST FRAME".
    can U plz tell me what could be the problem
    Bye
    AJAY

  • Can a transaction be called in background dynamically using ABAP program??

    Hi Experts,
    Can a transaction be called in background dynamically using ABAP program without BDC???
    Regards,
    Mansi.

    u can create job dynamically through programming..Try this sample code..
    data: jobname like tbtcjob-jobname value
                                 ' TRANSFER TRANSLATION'.
    data: jobcount like tbtcjob-jobcount,
          host like msxxlist-host.
    data: begin of starttime.
            include structure tbtcstrt.
    data: end of starttime.
    data: starttimeimmediate like btch0000-char1.
    Job open
      call function 'JOB_OPEN'
           exporting
                delanfrep        = ' '
                jobgroup         = ' '
                jobname          = jobname
                sdlstrtdt        = sy-datum
                sdlstrttm        = sy-uzeit
           importing
                jobcount         = jobcount
           exceptions
                cant_create_job  = 01
                invalid_job_data = 02
                jobname_missing  = 03.
      if sy-subrc ne 0.
                                           "error processing
      endif.
    Insert process into job
    SUBMIT zreport and return               << Here it is a static call but u can make it dynamic
                    with p_param1 = 'value'
                    with p_param2 = 'value'
                    user sy-uname
                    via job jobname
                    number jobcount.
      if sy-subrc > 0.
                                           "error processing
      endif.
    Close job
      starttime-sdlstrtdt = sy-datum + 1.
      starttime-sdlstrttm = '220000'.
      call function 'JOB_CLOSE'
           exporting
                event_id             = starttime-eventid
                event_param          = starttime-eventparm
                event_periodic       = starttime-periodic
                jobcount             = jobcount
                jobname              = jobname
                laststrtdt           = starttime-laststrtdt
                laststrttm           = starttime-laststrttm
                prddays              = 1
                prdhours             = 0
                prdmins              = 0
                prdmonths            = 0
                prdweeks             = 0
                sdlstrtdt            = starttime-sdlstrtdt
                sdlstrttm            = starttime-sdlstrttm
                strtimmed            = starttimeimmediate
                targetsystem         = host
           exceptions
                cant_start_immediate = 01
                invalid_startdate    = 02
                jobname_missing      = 03
                job_close_failed     = 04
                job_nosteps          = 05
                job_notex            = 06
                lock_failed          = 07
                others               = 99.
      if sy-subrc eq 0.
                                           "error processing
      endif.
    Regards,
    JOy.

Maybe you are looking for