Need help in writing ABAP Code

Hi All,
I have a scenario to write a code for below requirement to fetch a latest sales document based on Last Date of Change and Last Time Change and I have written below code in the transfer rule..
SORT datapak BY Sales Doc
  Last Date of Change Last Time Change descending.
DELETE ADJACENT DUPLICATES FROM DATAPAK
COMPARING Sales Doc
The above code works as per below details
Data is coming from source in FULL mode
Data in Source: Input
Sales Doc       Last Date of Change    Last Time Change    Order Reason
201                01/03/2014                   04:10:00                        A
201                 01/03/2014                   05:12:00                        B
Output: Data in DSO(after moving from transfer rule)
201                  01/03/2014                  05:12:00                        B             ------------------This is correct(record based on latest date of modification and time)
Data in source
Sales Doc       Last Date of Change    Last Time Change    Order Reason
201                01/03/2014                   04:10:00                        A
201                 02/04/2014                   05:12:00                        B
Data in output
201                01/03/2014                   04:10:00                        A 
201                 02/04/2014                  05:12:00                        B  -------------------------In this case code is not working when Last date of Modification is different, the DSO fetches both the records while it should fetch only record with latest Date of Modification and Time....
Could you pls advice if the code is correct or any changes to be made to the code..

Hi Antony,
Here the problem is of SORT statement when the Time has been introduced as the sorting factor.
Please apply below additional code and it will do the job for you.
*Additional Code
DATA: ls_datapak LIKE LINE OF datapak.
DATA: ls_datapak1 LIKE LINE OF datapak.
* First sort the datapack with only last change date
SORT datapak BY vbeln aedat DESCENDING.
* remove all the old dates first and keep only the latest change date in DATAPAK
READ TABLE datapak INTO ls_datapak1 INDEX 1.
LOOP AT datapak INTO ls_vbak.
  IF ls_datapak-aedat LT ls_datapak1-aedat.
    DELETE datapak INDEX sy-tabix.
  ENDIF.
ENDLOOP.
* below is your code
SORT datapak BY vbeln aedat lastchangetime DESCENDING.
DELETE ADJACENT DUPLICATES FROM datapak COMPARING vbeln.
Please let me know if you face any issue with this code.
Thanks
Amit

Similar Messages

  • Need Help With Simple ABAP Code

    Hello,
    I'm loading data from a DSO (ZDTBMAJ) to an Infocube (ZCBRAD06). I need help with ABAP code to some of the logic in Start Routine. DSO has 2 fields: ZOCTDLINX & ZOCBRDMAJ.
    1. Need to populate ZOCPRODCD & ZOCREFNUM fields in Infocube:
        Logic:-
        Lookup /BI0/PMATERIAL, if /BIC/ZOCBRDMAJ = /BIC/OIZOCBRDMAJ
        then /BIC/ZOCPRODCD = ZOCPRODCD in Infocube
               /BIC/ZOCREFNUM = ZOCREFNUM in Infocube         
    2. Need to populate 0G_CWWTER field in Infocube:
        Logic:
        Lookup /BIC/PZOCTDLINX, if /BIC/ZOCTDLINX = BIC/OIZOCTDLINX
        then G_CWWTER = 0G_CWWTER in Infocube.
    I would need to read single row at a time.
    Thanks!

    I resolved it.

  • Need help in writing the code

    Hi,
    My table data is as below.
    Kunnr  BDAT EDAT  D1 D2 D3 D4 D5
    1111    2001  2002   1      2    1      2     1
    1111    2003  2008   1      0    4     1      2
    1111    2008  2011   1      1    1     1      1
    2222    2003  2008   1      2    2             2
    2222    2008  2011           1    2     1      1
    Here for kunnr  between begin and end date we have to caluclate the dependencies. (I.e if there is any value in D1or D2 or D3orD4 it shoulbe counted as 1. of it is zero or blank then it should not be coutned).
    for Ex: for 1111 between 2001 & 2002 tot dependencies are 5.            
               for 1111 between 2003 & 2008 tot dependencies are 4.
    in this scenario what will be the best way of writing the code. Do we need to check each and every field when counting the Sum value or and simple way to improve the performance.
    Regards,
    Vishnu
    Edited by: Vishnuvadhan K on May 13, 2011 10:30 AM
    Moderator Message: This is not a forum, where you can get your work done by others.
    Edited by: kishan P on May 13, 2011 3:52 PM

    Hi Vishnu,
    Here, you will have to check for the range of your begin date & end date. If it comes in the said range, then you simply have to add the values of your D1, D2,... DX values which you can store in some variables by setting out a flag as one counter for each.
    If your case is satisfied for any of the date range, then just check for the flag values which are satisfied & add them or display the sum of the number of counters.
    @Ambujavalli, At End Of won't work here because the date ranges given by Vishnu will differ.
    Those statements are useful in a case when suppose for the same field value, you need to calculate a particular sum.
    Here, that is not the case. Hence, AT First & At End Of won't work.
    Thanks,
    Gayathri.
    Edited by: gnikesh88 on May 13, 2011 11:52 AM

  • Need help in framing ABAP code

    Hi,
    Can someone help me frame code for the below logic
    In start routine, if records that have a common record for PO 0OI_EBELN in ITROMML ODS and 0AC_DOC_NO on ITROFIL ODS , then the entire PO record details will be deleted from ITROMML ODS . Therefore  0AC_DOC_NO details from ITROFIL ODS will be filled in ITROCMH ODS and ITROCMD ODS.
    Logic is like : Using the Material Document Number ITRMATDOC, line item ITRMTDCLI and fiscal year 0FISCYEAR as key - open POs (0OI_EBELN) from ITROMML ODS are checked with invoices 0AC_DOC_NO in ITROFIL ODS and if the respective keys match, then the entire record is deleted from ITROMML ODS and only invoiced records are brought into the second level ODS ITROCMH and ITROCMD
    Here,
    ITROMML and ITROFIL are first level ODS
    ITROCMH and ITROCMD are second level ODS
    I need to write the start routine in between these two levels in BI.7

    any suggestions please?

  • Need help in writing ABAP for and Object

    Hi ,
    I am an ABAPer and I need a help related to BW.
    As per the Client Requirement ,I need to write ABAP for object  ZC_MRPAMC.
    what he expects is :
    0MRP_CONTROL is an attribute of 0MAT_PLANT. There can be only one 0MRP_CONTROL per  0MAT_PLANT.
    Assign the attribute value of 0MRP_CONTROL to ZC_MRPAMC per 0MAT_PLANT.
    How to assign value of 0MRP_CONTROL to ZC_MRPAMC per 0MAT_PLANT.
    Kindly  give me the steps.
    Thanks.
    Anu.

    Hi,
    U can use FM RSAU_READ_MASTER_DATA.
    Give as input the info object(I_IOBJNM=0MAT_PLANT) and attribute name(I_ATTRNM=0MRP_CONTROL).
    Output u will get the value of that attribute which u want(E_ATTRVAL=ZC_MRPAMC).
    Hope it helps
    Regards,
    Rathy

  • Need help in writing data from JSP to excel

    Hi ,
    I need help in writing the data from JSP to excel.I somehow able to retrieve the data into excel but unable to get the required format.
    For eg: The amount should be displayed in 0.00 format .when i am exporting it to excel it is displaying as 0 :( .
    I am using the following code in JSP.
    "out.print(amt + '\t');"
    Would like to know if there is any otherway where in i can get my requirement.
    Thanks
    Tom

    Hi,
    Try using format part of the JSTL tag libs.
    Syntax :
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <fmt:formatNumber value="40" pattern="$#,##0.00"/>
    I need help in writing the data from JSP to excel.I
    somehow able to retrieve the data into excelHow do u convert the jsp to excel?
    One way to convert the jsp page to excel, is to render it as an excel appl instead of html. Set the content type of the response to application/ms-excel.
    response.setContentType("application/ms-excel")Hope this Helps....

  • Need help for writing extract program

    hi
    i need help for writing extract program to retriew data from legacy system.
    i already developed bdc programs for me31k and me21.
    my requirement is to write extract program s for those t.codes.
    to retriew data from legacy system and stored in flat file.

    i need help with a java program. it is a program that allows the user to enter a student's GPA, number of extracurricular activities, and number of service activities. The user can not enter a gpa above 4.0 or below 0. The user can not enter a negative number for the number of both activities. If the student meets the following criteria: 1) GPA of 3.8 or above and at least one extracurricular activity and one service activity, 2) GPA below 3.8 but at least 3.4 and a total of at least three extracurricular and service activities, 3) GPA below 3.4 but at least 3.0 and at least two extracurricular activities and three service activities, the message "Scholarship candidate" should display. If the student does not meet the criteria above, then the message"not a candidate" should display. Can you help me, please?
    You haven't posted ANY 'java program' for us to help with.
    The forum is NOT a coding service. It is to help you with YOUR code.
    Post the code you have written and SHOW us (don't just tell us) how you compile it and execute it and the results you get. Then we can help you with any problems you are are having.
    If you need help understanding just what the program should be doing you need to ask your instructor to clarify the assignment.

  • Need help with a activation code for Adobe Acrobat X Standard for my PC,, Don't have older version serial numbers,  threw programs away,  only have Adobe Acrobat X Standard,  need a code to unlock program?

    Need help with a activation code for Adobe Acrobat X Standard for my PC, Don't have older Version of Adobe Acrobat 9, 8 or 7. 

    You don't need to install the older version, you only need the serial number from your original purchase. If you don't have them to hand, did you register? If so, they should be in your Adobe account. If not you really need to contact Adobe, though it isn't clear they will be able to do anything without some proof of purchase etc.

  • I need help getting new authorization codes for digital copies

    I need help getting new authorization codes for digital copies of movies. Can someone help me out?

    There's a lot of results in Google when you search for this but unfortunately refreshing the page doesn't seem to generate a different code anymore. Mine also says already redeemed

  • Require  help in my ABAP code

    Hi All,
    My design wont allow Delta loads because the transformation source is an InfoSet.  To limit the data in these loads, I require a  filter in the DTPs on fiscal year/period then only load I can load the current month and 2 prior months.  Now we are updating manually for the DTPs.   To eliminate this monthly task a dynamic filter (routine) needs should be used rather than a static filter.
    So I have written as follows  But in the debugger mode am able to see the -3months to the current date but records are not filtered. Any help please
    *&  Include           RSBC_SEL_ROUTINE_TPL -
    program conversion_routine.---
    Type pools used by conversion program---
    type-pools: rsarc, rsarr, rssm.---
    tables: rssdlrange.---
    Global code used by conversion rules---
    $$ begin of global - insert your declaration only below this line  ----
    TABLES: ...---
    DATA:   ...------
    $$ end of global - insert your declaration only before this line   ----
        Fieldname       = F139---
        data type       = NUMC---
        length          = 000007---
    form compute_F139---
      tables l_t_range structure rssdlrange---
      changing p_subrc like sy-subrc.---
          Insert source code to current selection field---
    $$ begin of routine - insert your code only below this line        ----
      data: l_idx like sy-tabix.---
      read table l_t_range with key---
           fieldname = '/bic/0FISCPER' .---
      l_idx = sy-tabix.---
      DATA: w_date TYPE SY-DATUM,---
          w_date1 type sy-datum,---
          lv_idate(8) type n,---
          lv_odate(8) type n,---
          lv_date1(7) type n,---
          lv_date2(8) type n.---
      CONCATENATE SY-DATUM0(4) SY-DATUM4(2) sy-datum+6(2) into W_DATE.---
      CALL FUNCTION 'SEPA_MANDATE_ADD_MONTH_TO_DATE'---
        EXPORTING---
          MONTHS  = '-3'---
          OLDDATE = W_DATE---
        IMPORTING---
          NEWDATE = W_DATE1.---
      Concatenate W_DATE0(4) W_DATE4(2) W_DATE+6(2) into lv_Idate.---
      Concatenate W_DATE10(4) W_DATE14(2) W_DATE1+6(2) into lv_odate.---
      Concatenate '0' W_DATE4(2) '.' W_DATE0(4) into lv_date2.---
       Concatenate '0' W_DATE14(2)  W_DATE10(4) into lv_date1.---
    CALL FUNCTION 'UMC_CALDAY_TO_FISCPER'---
       EXPORTING---
        I_PERIV    = 'K1'---
        I_CALDAY   = lv_Idate---
       IMPORTING---
         OUTPUT = lv_date1.---
    CALL FUNCTION 'UMC_CALDAY_TO_FISCPER'---
       EXPORTING---
        I_PERIV    = 'K1'---
        I_CALDAY   = lv_odate---
       IMPORTING---
         OUTPUT = lv_date2.---
    *l_t_range-iobjnm = '0FISCPER'.---
    l_t_range-fieldname = '/bic/0FISCPER'.---
    l_t_range-sign = 'I'.---
    l_t_range-option = 'GE'.---
    l_t_range-low = lv_date1.---
    *l_t_range-high = lv_date2.---
      if l_idx <> 0.---
        modify l_t_range index l_idx.---
      else.---
        append l_t_range.---
      endif.---
      p_subrc = 0.---
    $$ end of routine - insert your code only before this line         ----
    endform.---
    -Ashwin
    Edited by: ashwin kumar on Jun 16, 2010 10:04 AM

    1. In the future, please use a meaningful subject line, like "loop not performing last iteration." Just saying "Help in my java code" is useless. We know you need help with your Java code, else you wouldn't be posting here.
    2. Repost your code without those annoying superfluous asterisks, and with proper indentation in the section that they are currently polluting. It's too hard to read as-is.

  • Need help to master ABAP

    I need help to master ABAP.
    Please email me....if u can help me : [email protected]
    I am looking for help with IDOC, ALE, RFC and BAPI.
    Please send me mail. We can talk more.

    Jeff,  please ask specific questions here.  The answer will come.  Try to not ask for material to be sent directly to you.  This is not in the community spirit as it will only benefit you.  Also you might want to try the search functionality on this site.  There is plenty of info out there.
    Regards,
    RIch HEilman

  • Need help to redeem contact code for OS X 7

    Need help to redeem contact code for OS X 7

    Hello NOREDEEM,
    Thanks for using Apple Support Communities.
    If you have the purchase code for OS X 10.7 Lion, then you can follow the directions below to redeem it on your Mac.
    Mac App Store: Redeem gift cards and download codes
    Take care,
    Alex H.

  • I need help I scratched the code off my itunes card

    I need help I scratched the code off my itunes card

    Click here and ask the iTunes Store staff for assistance. Supply them with as much of the code as you can.
    (102006)

  • Need help in writing a small java code

    Hi,
    I have a small requirement where I need write a small java code. I am thinking of using array. Please suggest if you know the solution:
    1. Need to compare user logon id is preset in the lookup table or not.
    2. If user id present in the lookup then send type "A" mail
    3. If user id in not present in the lookup then send type "B" email.
    Please suggest.
    Thanks,
    Kalpana.

    use this code . you have to pass userlogin and lookup name
    Public String GetEmail(String UserLogin,String lookupcode)
    String email;
    try{
    tcLookupOperationIntf lookupIntf = Platform.getService(tcLookupOperationIntf.class);
    HashMap<String, String> lookupValues = getLookupHashMap(lookupIntf, lookupCode);
    String found = lookupValues.get(UserLogin);
    if (found!=null) email= "EMAIL A";
    else
    email= "EMAIL B";
    }catch(Exception e){}
    return email;
    private HashMap<String, String> getLookupHashMap(tcLookupOperationsIntf lookupOperationsIntf, String lookupCode)throws tcAPIException,tcInvalidLookupException,tcColumnNotFoundException {
    HashMap<String, String> lookupMap = new HashMap<String, String>();
              tcResultSet resultLookupHashMap = lookupOperationsIntf
                        .getLookupValues(lookupCode);
              int countResultLookupHashMap = resultLookupHashMap.getRowCount();
    if (countResultLookupHashMap > 0) {
                   for (int i = 0; i < countResultLookupHashMap; i++) {
                        resultLookupHashMap.goToRow(i);
                        lookupMap.put(resultLookupHashMap..getStringValue("Lookup Definition.Lookup Code Information.Code Key"),
    resultLookupHashMap.getStringValue("Lookup Definition.Lookup Code Information.Decode"));
    return lookupMap;
    }

  • Need Help in writing a UDF

    Hi,
    Please help in writing a UDF for these fields in mapping, which I need for the object Iu2019m doing currently.
    The fields are like this:
    1)         batch_no = "TRUNC((GetMaxObjid('x_txn_sap_parts')-POWER(2,28))/5000)+1",
    2)         lot_id = "TRUNC((GetMaxObjid('x_txn_sap_parts')-POWER(2,28))/500)+1",
    3)        How to use JDBC connection factory class in the UDF.
    Some logic I can provide which I know i.e. Power (2, 28) means 2 to the power of 28 (2 multiplied 28 times), Trunc means truncate, X_TXN_SAP_Parts is a database table.The Target fields are Batch_no, lot_id & Objid.Actually, objid is mapped initially to a source field i.e. Object ID and in this function it is only being used for the calculation of the batch_no.
    Thanks in Advance,
    Sreedhar.

    Hi,
    Following with my query I've tried to use this code but still I'm unable to execute the mapping.
    import java.util.*;
    import com.sap.aii.mapping.lookup.*;
    import com.sap.aii.mapping.lookup.*;
    DataBaseAccessor accessor = null;
    DataBaseResult JDBCOutPayload = null;
    String BusinessSystem="clarify_dev_bizsys";
    //give your business system having channel name
    String CommunicationChannel="JDBC_TO_CDEV";
    //give your channel name
    String InputPayload= " select X_TXN_PRE_SITE_XFACE.nextval from dual;";
    //give your sql query
    try {
    Channel channel =
    LookupService.getChannel(BusinessSystem,CommunicationChannel);
    accessor = LookupService.getDataBaseAccessor(channel);     
    DataBaseResult resultSet = accessor.execute(InputPayload);
         for(Iterator rows = resultSet.getRows();rows.hasNext();){  
         Map rowMap = (Map)rows.next();
         Object cValue = rowMap.get("batchno");
    //field name of field required , as in database
          catch (Exception e) {}
          finally {
                  if (accessor != null)
                  accessor.close();
           result.addValue((String)cValue);
    --> I don't know what are the parameters to be used and how to be used in the UDF because this is the first time I'm writing a UDF.
    --> The problem in using this query is that both OBJID & BatchNo. are on the target side and the value for the OBJID is retrieved by a SELECT query from the database.
    Kindly help me how to resolve this query of mine.
    Thanks in Advance.
    Sreedhar.

Maybe you are looking for

  • Two questions about ATI RADEON HD 3870

    I've been in touch with macsales.com and they recommend the ATI RADEON HD 3870 for the Mac Pro Xeon (late 2006-2007) running 10.5. But they were unable to answer w/ 100% certainty: 1. That all I need to connect this card (it has 2 DVI ports) to my Sa

  • EIC issue on adding employee survey link

    Hi Experts, We are trying to attach a customer/employee survey link in EIC. Example: 1.We have created a Appraisal template 2.And assign Templates to Status and Category/Subcategory 3.While trying to create URL though class CL_HREIC_EESURVEY itu2019s

  • FMS3: Delay in start of video stream; error

    Hi, We're setting up an FMS3-based video streaming system for a new website, and have built a player using AS2 (for compatibility with Flash Player v8) and the FLVPlayback componenent which uses FMS3's new native bandwidth checking to provide us with

  • Without sound, and doesn't aloud me to turn it on

    Hello sorry for my english, I'm from Argentina. Recently I´ve installed mountain lion and today I realised that my notebook doesn't have sounds, the icon apears in grey, and in sistem preferences apear off, but I can't turn on like in the picture. Pl

  • Iphone, ipod wont mount on iMac 27 inc i5 iTunes & iPhoto

    Dear All I have had my new iMac 27 inch i5 for a week and all was well until (i think) last software update which had an iPhone SDK, I can mount drives fine to desktop still but I can't mount iPhone or iPod to iMac yes I have checked cables and both