Some ABAP Code Help

Hello,
I have a transformation mapped from a DSO (ZD_QDCOL ) to an InfoCube. I need to create new records in the Cube by comparing data records from 2 DSO's: ZD_QDCOL (with & without Depletions) and ZDTDBMAJ (only with Depletions). Both the DSO's have 2 key fields: ZOCTDLINX & ZOCBRDMAJ.
Logic:
a. Read single row
      If 'ZOCTDLINX' from ZD_QDCOL  = 'ZOCTDLINX' from ZDTDBMAJ
        And 'ZOCBRDMAJ' from ZD_QDCOL  = 'ZOCBRDMAJ' from ZDTDBMAJ
           then ignore this record
     Else
       add this row to the Cube.
b. Also, for 'ZOCBRDMAJ' field in DSO ZDTDBMAJ, I need to strip the last 3 digits from every data record before doing the comparison in (a).
Please suggest.
Thanks!

Hi Krishna,
     U need to load data from dso (with and without depletions)  to cube.... and if the data in dso( depletions ) based on key matches that data should be removed ....that means u need to load data for not depletions.....and while making comparsion u need to remove last three digits .....
I will provide sample code for this.... u write in the start routine in the transformation to cube...
types : begin of it_type,
                   ZOCTDLINX     type /bic/oiZOCTDLINX,
                   ZOCBRDMAJ  type /bic/oiZOCBRDMAJ,
         end of it_type.
data : itab type standard table of it_type.
data : wa_itab like line of itab. 
data : count(1) type n.
data : wa_source_package type tys_SC_1.
Select /BIC/ZOCTDLINX  /BIC/ZOCBRDMAJ
         from /BIC/AZDTDBMAJ00
         into table itab
         for all entries in source_package
         where /BIC/ZOCTDLINX = source_package-/BIC/ZOCTDLINX
         and /BIC/ZOCBRDMAJ (x)= source_package-/BIC/ZOCBRDMAJ(x).
***x is ur length of object minus 3 as u told to strip last threee
loop at source_package into wa_source_package.
   count = 0.
       loop at itab into wa_itab.
               if wa_itab-ZOCTDLINX = wa_source_package-/BIC/ZOCTDLINX
                       and  wa_itab-ZOCBRDMAJ (x)= wa_source_package-/BIC/ZOCBRDMAJ(x).
                          count = 1.
                          exit loop.
               endif.
        endloop.
if count = 1.
       clear wa_source_package.
       modify source_package from  wa_source_package.
endif.
endloop.
In the code first i am bringing the values form the second ods into an internal tab provided the two keys are matching ..... as u are writing in start routine of ods 1 it is nothing but u are comparing ods1 and ods2....
in internal table after select statement u will have all the values common to both coming in source_package...
next i made aa loop again and cleared the ones from source_package which are same
any doubts get back to me...
Regards
vamsi

Similar Messages

  • ABAP code Help for Customer Exit variable

    Hello All,
    Can anyone provide ABAP code for a customer exit variable please?
    Requirement:
    0CALYEAR(InfoObject) - ZCALCYR (Variable) <b>Calender year with default value actual year</b>.
    Proiperties of variable: single value,mandatory,ready for input,can'be changed in query navigation.
    i have read some docs on customet exit variables which i got from SDN but i found it's difficult for me to get this as i am not that good in ABAP.
    Thanks,
    Rakesh.

    Hi,
       Just check the below code. You just need to make slight changes I believe. Hope this helps you.
    In CMOD………..
    Sample code
      INCLUDE LXRSRF01                                                   *
    data: l_s_range type rsr_s_rangesid.
    case i_vnam.
      when 'ZCALCYR'.
        if i_step = 1.
         l_s_range-low = sy-datum+0(4).
            append l_s_range to e_t_range.
        Endif.
    Endcase.

  • Urgent: ABAP Code help reqd

    Hi,
    Can anyone please me provide me ABAP code for the following case:
    Table1 – JHAGA
    Table2 – JHAGVZ
    Primary keys in JHAGA:
    Order Item Number [POS_NR]
    Billing Dataset [GRUPPABRNR]
    Sales Document Number [AVM_NR]
    This requirement is for an InfoSet. For each order ideally we can have multiple sales agent. Sales Agent is being pulled from JHAGVZ. For this InfoSet we are going to go with assumption that we wont have more then 10 sales agent for an order,
    Consider 10 extra fields in InfoSet SA1 – SA10 for 10 Sales Agent.
    I need code which to populate this sales agent field. If an order exists in JHAGA then for that order in JHAGVZ populate the SA1-SA10 field.
    JHAGA – Order#10
    JHAGVZ – Order#10 – SalesAgent11
                   SalesAgent12
                   SalesAgent13
    Then SA1 should have SalesAgent11, SA2 should have SalesAgent12 and SA3 should have SalesAgent13 and so on…     
    Thank you,
    sam

    HI ,
    Are these two field a part of the table INFOROBJECT?
    if they are, you can write a select statement like :
    select 0CUSTOMER 0SALESORG YLEG_ENTITY
           from INFOROBJECT
           into Y_CUST_LE
           where ( Yacc_SEQ <> ´ZROO´  and
                   0PRICE_LIST <> space).
    Hope this helps.
    If not, please explain problem clearly.

  • Abap Code help in Extractor!!!

    Hi all
    I am not an abaper, I am using Bw 3.5; I need to write a code in "ZBSIS" and "ZBSAS" Extractor Include program ZXRSAU01: so that the report based on cube "ZBSISAS" shows values for field Transaction key "ZKTOSL".
    The field "KTOSL" is not active in R/3 Directory and gets filled in program RFWERE00 in Tcode F.19 in R/3.
    I have to use the same logic in extractor as used in that program.
    The logic is:
    FORM GET_'KTOSL USING IAMOUNT LIKE EXTRACT-DMBTR
                                   CHANGING 'EKTOSL' LIKE POST_COLLECT-'KTOSL'.
               IF IAMOUNT < 0.
                  'EKTOSL' = 'GNB'
               ELSE.
                  'EKTOSL' = 'BNG'
               ENDIF.
    ENDFORM.
    Can any of you advice me on abap code for this logic?
    I appreciate your help.
    Thanks in advance
    Ishi

    Hi,
    You can use the following code in ZXRSAU01.
    CASE i_datasource.
    WHEN 'ZBSIS'.
    DATA: g_wa_extractstructure  LIKE <give the extractstructure  of your datasource from RSA2>.
    LOOP AT C_T_DATA into g_wa_extractstructure.
    IF g_wa_extractstructure-DMBTR LT 0.
    g_wa_extractstructure-ZKTOSL = 'GNB'
    ELSE.
    g_wa_extractstructure-ZKTOSL = 'BNG'
    ENDIF.
    MODIFY c_t_data FROM g_wa_extractstructure.
    ENDLOOP.
    ENDCASE.
    Note:- . The same code can be used for ZBSAS. Please make sure to give the  extract structure name in the field marked in <->.
    Thanks,
    Nithin reddy.

  • Abap Code help in update rule

    Hi Gurus,
    I have  a requiement, that is if there are 5 line items with in a document and each one has diffeerent tax jurisdiction code, then we should be showing only one tax jurisdiction code for a document. Line items are not displayed in report. The condition to pick up tax jurisdiction code is the one which has least ending zeros among all the lime items with in a document.
    Supppose
    Doc1 Item Tax Jurisdiction code
    1800000002 1 CNQC00000000000
    1800000002 2 CNQC00000000000
    1800000002 3 CN0000000000000
    1800000002 4 CNQC00000000000
    1800000002 5 TXJOHNCLEBUR000
    So here the value of Tax Jurisdiction code is TXJOHNCLEBUR000 as it has least ending zeros compared to other values with in a document.
    Any help how to use the string function and acheive the desired result.
    Thanks,
    Raj.

    Hi Anand,
    Thanks for the reply. we don't expect any non-zeros after seeing first zero. Now i have added another z object which will contain only least zeros for a doc. What I am doing is now after loading the data into the cube from ods  i am doing loop back and updating the new z object. Below is the code I am trying to do
    TABLES: /BIC/AZFGLO10100.
    Defining an internal table as ods table****
    Types: BEGIN OF ITAB_01,
    doc_no LIKE /BIC/AZFGLO10100-AC_DOC_NO,
    item_no LIKE /BIC/AZFGLO10100-ITEM_NUM,
    taxjur LIKE /BIC/AZFGLO10100-TAXJURCODE,
    length like num,  ***** this will hold the length of the zeros
    END OF ITAB_01.
    loading the data from active ods table into defined internal table*****
    select AC_DOC_NO ITEM_NUM TAXJURCODE  from /BIC/AZFGLO10100 into table
      Itab_01 where AC_DOC_NO = /BIC/AZFGLO10100-AC_DOC_NO and
      item_num = /BIC/AZFGLO10100-ITEM_NUM.
    sort itab_01 doc_no item_no
    now I want to use code too populate the vlaue of length field in internal table (which shows how many zeros a tax jurisdiction code has for every corresponding line item)
    then in the update rule of z tax jurisdiction i will wirte a routine such that
    select taxjur into result from itab_01 where doc_no = COMM_STRUCTURE-doc_no and length = min(length).
    now I have one more doubt , the number of items in a document will be varying so how to takecare of this...
    If possible can you please provide me with the abap code that you have mentioned in earlier post.
    Any more help on this is really appreciated.
    Thanks,
    Raj

  • ABAP code help for Bex broadcasting by event!

    Hello
    I'm trying to broadcast a report for a specific time period as per factory calendar. I tried using System Time Point :RSRD_BROADCAST_FOR_TIMEPOINT but its not showing when In the broadcaster when I put restriction of factory calendar so i followed below link: Broadcasting timepoint scheduled after an event and created a PC to start after event and created variant for RSRD_BROADCAST_STARTER setting ID as my Bes broadcast setting technical name.
    When I trigger the event its processed and report emailed to me as I expected. Now I want to run this (Trigger) this event every Wed day after fisc quarter close. I wrote the below logic in se38 PROGRAM. But Now I need little help on how to trigger /run only on wed days after fisc quarter close ? Please update the below code or guide me on how to achieve this.
        CALL FUNCTION 'BP_EVENT_RAISE'
          EXPORTING
            EVENTID = ZFISC
      endif.
    Thanks

    in your ABAP code try this,
    calculate whether current date falls after fiscal year quarter. If so then check whether its a Wednesday and call the event raise FM. You can schedule this program in background daily basis.
    Use this FM for day calculation DATE_TO_DAY.
    This FM for converting sy-datum to fiscal year/period - FI_PERIOD_DETERMINE,DATE_TO_PERIOD_CONVERT

  • Survey creation abap code help needed

    hello experts,
    I need to create a survey in crm, by taking values from end-user from a webpage
    A sample code help is needed.
    Thanks in advance

    Take a look at this SAP note - It does a pretty good job of detailing the steps for you.  No coding necessary, it worked out of the box for us after patching this note.
    https://service.sap.com/sap/support/notes/638320

  • Need Abap Code Help

    Hi ,
    I am trying to activate an ODS but it is failing the activation process . When I look into the application log I see this error    "Value 'RAM???¿????????S RAM' (hex. '4D41524B3F3F3FBF3F3F3F3F3F3F3F3F5320574F524B') of characteristic ZEUID contains invalid characters "
    I am new to ABAP and I need an ABAP code to filter this value when loading data into ODS .
    Thanks a lot for your help

    HI,
      Write the code in the start routine.
      IN the start routine you have a table called SOURCE_PACKAGE.
      declare work area x_souce_package type source_package
    data : lv_string(100).
      loop at souce_package into x_source_package.
      lv_string =  x_source_package-value.
    TRANSLATE LV_STRING TO UPPER CASE
      if lv_string CA 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' .
      ELSE.
      DELETE SOURCE_PACKAGE INDEX SY-TABIX.
      ENDIF.
      endloop

  • Help with some ABAP code

    I am trying to fill the quantity value if it is blank by looking for a record with the key and putting it's value in it.  the code is below but the part whee it says where order_qty > 0 is not working.  It just hops out even if it is.
    CLEAR: T_SCHED_DATA, T_QUANTITY_DATA.
      REFRESH: T_SCHED_DATA, T_QUANTITY_DATA.
      SELECT DOC_NUMBER S_ORD_ITEM SCHED_LINE DSDEL_DATE REQ_DATE ORDER_QTY
       INTO TABLE T_SCHED_DATA
       FROM /BIC/AZSCH_O5400
         FOR ALL ENTRIES IN DATA_PACKAGE
        WHERE
         DOC_NUMBER = DATA_PACKAGE-DOC_NUMBER AND
         S_ORD_ITEM = DATA_PACKAGE-S_ORD_ITEM AND
         SCHED_LINE = DATA_PACKAGE-SCHED_LINE.
      SELECT DOC_NUMBER S_ORD_ITEM SCHED_LINE DSDEL_DATE REQ_DATE ORDER_QTY
       INTO TABLE T_QUANTITY_DATA
       FROM /BIC/AZSCH_O5400
        FOR ALL ENTRIES IN T_SCHED_DATA
        WHERE
         DOC_NUMBER = T_SCHED_DATA-VBELN AND
         S_ORD_ITEM  = T_SCHED_DATA-POSNR.
      T_QUANTITY_DATA2[] = T_QUANTITY_DATA[].
      sort t_quantity_data2 by vbeln posnr SCHED_LINE
           ascending.
    sort t_quantity_data by vbeln posnr SCHED_LINE
           ascending.
      loop at T_QUANTITY_DATA into LF_DATA
        where order_qty > 0.
          loop at T_QUANTITY_DATA2 into LF_DATA2
          where
           vbeln = LF_DATA-VBELN AND
           posnr = LF_DATA-POSNR AND
           DSDEL_DATE = LF_DATA-DSDEL_DATE AND
           SCHED_LINE NE LF_DATA-SCHED_LINE and
           order_qty = 0.
            lf_data3 = lf_data2.
            move LF_DATA-order_qty to lf_data3-order_qty.
            append lf_data3 to T_QUANTITY_DATA3.
          endloop.
      endloop.

    loop at T_QUANTITY_DATA into LF_DATA
    where <b>order_qty > 0.</b> <b> " when this is greater than zero</b>
    loop at T_QUANTITY_DATA2 into LF_DATA2
    where
    vbeln = LF_DATA-VBELN AND
    posnr = LF_DATA-POSNR AND
    DSDEL_DATE = LF_DATA-DSDEL_DATE AND
    SCHED_LINE NE LF_DATA-SCHED_LINE and
    <b>order_qty = 0.</b>  <b>" how can it be zero here</b>
    lf_data3 = lf_data2.
    move LF_DATA-order_qty to lf_data3-order_qty.
    append lf_data3 to T_QUANTITY_DATA3.
    endloop.
    endloop.

  • ABAP Code Help needed in DSO

    Hi All,
    My requirement is below :
    In my DSO I have the data as below
    doc number     item     con type     Agreement
    100     10     adc     1234
              efg     5678
              hij      ' '
    200     20     adc     1234
              efg     ' '
              hij      5678
    Now I have created a New Info object named flag. So now I am doing a self myself data mart where i need to write my routine to set data in the flag.
    The data should be like
    doc number     item     con type     Agreement   Flag
    100     10     adc     1234               X
              efg     5678               X
              hij      ' '                     X
    200     20     adc     1234               X
              efg     ' '                    X
              hij      5678              X
    Note:- even if agreement is blank for hij we need to put X since agreement is available for the remaining two condition types.
    Please can any one help with the code.and also please let meknow whether we shold write it in start routine or end routine
    Thanks In advance
    Sree

    Hi Rookie ,
    If i write the code below
    DATA: ITAB TYPE TABLE OF tys_TG_1,
               ITAB_WA TYPE tys_TG_1.
    MOVE RESULT_PACKAGE[] TO ITAB[].
    LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
       IF <RESULT_FIELDS>-AGREEMENT IS NOT INITIAL.
            <RESULT_FIELDS>-FLAG = 'X'.
       ELSE.
            LOOP AT ITAB INTO ITAB_WA WHERE AGREEMENT IS NOT INITIAL AND
                                    DOC_NO = <RESULT_FIELDS>-DOC_NO AND
                                    ITM_NO = <RESULT_FIELDS>-DOC_NO.
                 <RESULT_FIELDS>-FLAG = 'X'.
                  EXIT.
            ENDLOOP.
       ENDIF.
    ENDLOOP.
    My requirement doesnt match
    My requirement is below
    doc number    item     con type        Agreement
    100                 10           adc            1234
                                         efg             5678
                                          hij                ' '
    200                  20          adc             ' '
                                         efg               ' '
                                          hij                ' '
    Expected result is
    doc number    item     con type        Agreement    flag
    100                 10           adc            1234                x
                                         efg             5678                 x
                                          hij                ' '                     x
    200                  20          adc             ' '                     ' '  
                                         efg               ' '                    ' '
                                          hij                ' '                     ' '
    regards
    Sree

  • SAP Query :: ABAP Code Help

    Hi,
    I have created a query which reads a material Table and has consumption by date. What I want the report to do is show me a total number of PO's by month. i.e. below
    Any idea how can I go about this? I can understand ABAP but don't know how to put it in buckets via a query i know i have to create 12 fields called Jan, Feb, March, April etc but need the code to put date in the tables by month
    E.g.
    Material                          January    Feb   March   April       etc
    MAT1                                 23         22      21       11
    MAT2                                 35         67      89       33         etc
    THanks

    ABAP Program created

  • ABAP code help to replace one field with another

    Hi All,
    I have one DSO which is holding data for fields WBS(Old) and Company Code(Old).
    and I have one table which holds the information for Ols WBS and Ols Comp Code along with their New WBS and New Comp code.
    for eg:
    In DSO :
    Old WBS , Old Comp.Code
    abc        ,  001
    xyz        , 002
    In Table:
    Old WBS , Old Comp.Code , New WBS , New Comp.Code
    abc,           001,                    ABC,            001-04
    xyz,           002,                    XYZ,            002-04
    Now my requirement is ,
    search record by record from DSO and look into the table .
    If abc record in DSO matches with abc record in table, then in DSO it should replace with new WBS and Com.Codes.
    after the code, data in DSO shuld be lik this.
    WBS , Comp.Code
    ABC ,  001-04
    XYZ,   002-04.
    Thanks in advance,
    Sai Chand.S

    Hi
    If these fields are key fields dont think its possible to overwrite. Else plz write the following Code in End Routine it will overwrite the existing values in DSO.
    Select * from DSO into it_dso_temp. "U can even select only key fields WBS and CC fields.
    If sy_subrc=0.
    Sort it_dso_temp by WBS CC.
    endif.
    Select old WBS
               old CC
               new WBS
               new CC
    from Table
    into it_table
    for all entries in it_dso_temp
    where old WBS = WBS and old CC = CC.
    if sy_subrc=0.
    sort it_table by old WBS, old CC.
    endif.
    Loop at it_dso_temp assigning result_fields.
    Read it_table into wa_table with key old WBS = fs_dso_temp-WBS
                                                               old CC = fs_dso_temp-CC Binary SEarch.
    If sy_subrc = 0.
    result_fields-WBS = wa_table-new WBS.
    result_fields-CC = wa_table-new CC.
    endif.
    Endloop.
    Refresh result_package.
    result_package[] = it_dso_temp[].
    Also if incoming data has only old values u can loop at result package instead of it_dso_temp. let me know in case of issues.
    hope this helps !
    Reg
    Aparna

  • ABAP code help for 0PROFIT_CTR  (in Update rules)

    Hi
    Can you please give me the update rules code that would do the following in BW 3.5:
    If Profit Center is 10 digits long, its ok but if Profit Center is 5 digits long, concatenate with 5 zeros.
    Thanks
    Jimi
    Edited by: jimi ogun on Dec 1, 2011 1:44 PM

    Hi Soorej
    I tried teh code in my transfer rules but the result was blank. I guess it was because i didnt insert anything in the RESULT line... This is what i tried to do but i get a syntax error:
    $$ begin of routine - insert your code only below this line        -
    DATA: l_s_errorlog TYPE rssm_s_errorlog_int.
    data : len type i,
          v1(10) TYPE c value 'abcde'.
    len = strlen( v1 ).
    if len = 5.
    CONCATENATE v1 '00000' into v1.
    endif.
      RESULT = /BI0/OIPROFIT_CTR.
    returncode <> 0 means skip this record
      RETURNCODE = 0.
    abort <> 0 means skip whole data package !!!
      ABORT = 0.
    The syntax error i get is below:
    E:Field "/BI0/OIPROFIT_CTR" is unknown. It is neither in one of the
    specified tables nor defined by a "DATA" statement. "DATA" statement.

  • ABAP code help for 2004s

    Hey All,
    Could any one suggest a replacement code for the below 3.5 code in 2004s.
    If Movetype = 101 or 102 I want to update the result else I dont want to update that field. I couldnt find raise exception for thid in 2004s. Any other way to do it.
    IF COMM_STRUCTURE-MOVETYPE = '101' or COMM_STRUCTURE-MOVETYPE = '102'.
      RESULT = 'F'.
    ELSE.
    if the returncode is not equal zero, the result will not be updated
      RETURNCODE = 1.
    ENDIF.
    in 2004s
    IF SOURCE_FIELDS-MOVETYPE = '101' or SOURCE_FIELDS-MOVETYPE = '102'.
         RESULT = 'F'.
    ELSE
    *--  fill table "MONITOR" with values of structure "MONITOR_REC"
    *-   to make monitor entries
    ... "to cancel the update process
       raise exception type CX_RSROUT_ABORT.
    ... "to skip a record
       raise exception type CX_RSROUT_SKIP_RECORD.
    ... "to clear target fields
       raise exception type CX_RSROUT_SKIP_VAL.
    ENDIF.
    raise exception type CX_RSROUT_SKIP_VAL. looks to be close but it doesnt work. Can anyone explain what exactly the raise exception type CX_RSROUT_SKIP_VAL. does.
    Thanks,
    KK

    KK,
    From the comment, it is obvious that CX_RSROUT_SKIP_VAL clears the contents of the field. If you want to keep the value that was sent by the source system, just don't do anything. Don't even raise an exception.
    IF SOURCE_FIELDS-MOVETYPE = '101' or SOURCE_FIELDS-MOVETYPE = '102'.
      RESULT = 'F'.
    ENDIF.
    If the above code doesn't work, then you might try saving the value temporarily and then reassigning it.
    l_var = result.
    IF SOURCE_FIELDS-MOVETYPE = '101' or SOURCE_FIELDS-MOVETYPE = '102'.
      RESULT = 'F'.
    ELSE
      result = l_var.
    endif.

  • Abap Code help for retreiving user ID

    Hi All,
    I have a field N_BPIID(this field contains User IDs of Users) and variable on this field Z_PIID(Customer exit)...........
    My requirement is
    When i execute the report -
    this variable Z_PIID should automatically  retrive his ID frm BI/BW system..............
    Please suggest
    Edited by: Raj on Jan 12, 2010 4:59 AM

    Hi,
    A user that is signed on - system will populate field sy-uname - Not sure of your logic.In STEP 3 of your CMOD you could say :
    Eg : If user is not user "USERABC" then dont allow them into queries.
    Hope this helps    Colin
    IF sy-uname+0(7) <> 'USERABC'.
          L_AUTH = 0.
          EXIT.
        ENDIF.
      if sy-subrc <> 0.
        CALL FUNCTION 'RRMS_MESSAGE_HANDLING'
          EXPORTING
            I_CLASS  = 'RSBBS'
            I_TYPE   = 'E'
            I_NUMBER = '013'
            I_MSGV1  = 'Insufficient authorisation'.
        RAISE wrong_entry.
      endif.

Maybe you are looking for

  • Safari won't open page due to certificate error

    I incorrectly clicked on something when opening a new page and now the page won't open anymore.  The error I get is "the server "shop.rcbs.com" did not accept the certificate".  How do I fix this? JT

  • Audio shortcut will not load on b

    The to XP Pro and must be manually added to the control bar. It is set in preferences to load automatically but does not! Any Ideas? Thanks

  • What's that beeping sound?

    Just got this new MBP and I'm loving it for the gorgeous screen, the speed with which it handles pro apps and the lack of overheating. However, what I'm experiencing that I didn't with my old Core Duo 17" is this fairly regular beeping sound coming o

  • How to install software from download

    I'm new to the mac world. I'm using move2mac to move files over from pc. I downloaded and installed the software to my pc, but when I download the software for mac the install comes out in a weird format. (pkg.html)?

  • After Software Update Only Logo and Spinning Wheel Appear

    After downloading latest versions of Safari, OSX, and iTunes suggested via software update, a message stating that not all software (iTunes) instatlled. Restart resulted in the Apple logo and spinning wheel and never continued to completion. A hardwa