BADI_LE_SHIPMENT : how to do the declaration

Hi Friends:
I'm using BADI : BADI_LE_SHIPMENT to put some validations in trabsaction VT01N. inside that BADi there is a deep structure IM_SHIPMENTS_BEFORE_UPDATE . I've to use the internal tables inside that like new_vttk.....using the fields of table new VTTK & newVTTP..I've to write some validation...
plz guide me that how can I access the fields of these tables...
suitable points will be rewarded..
Regards:
Gaurav

see the following code used in at save method
DATA: wa_vbuk TYPE vbuk,
        wa_vttp TYPE vttp,
        wa_vttk LIKE LINE OF cha_shipments_at_save-new_vttk,
        w_fwdagent TYPE vttk-tdlnr,
        w_extid TYPE vttk-exti1.
  LOOP AT im_shipments_at_save-new_vttp INTO wa_vttp.
    SELECT SINGLE * FROM vbuk INTO wa_vbuk
               WHERE vbeln = wa_vttp-vbeln
                 AND wbstk = 'C'.
    IF sy-subrc NE 0.
      READ TABLE im_shipments_at_save-new_vttk INTO wa_vttk
                              WITH KEY tknum = wa_vttp-tknum.
      IF sy-subrc = 0 AND ( wa_vttk-stabf = 'X' OR
                            WA_VTTK-STDIS = 'X' OR
                            WA_VTTK-STREG = 'X').
        cha_shipments_at_save-old_vttk[] =
                        im_shipments_at_save-old_vttk[].
        cha_shipments_at_save-new_vttk[] =
                        im_shipments_at_save-new_vttk[].
        READ TABLE cha_shipments_at_save-new_vttk
        INTO wa_vttk INDEX 1.
        IF sy-subrc EQ 0.
          CLEAR: wa_vttk-stabf,
                 wa_vttk-uzabf,
                 wa_vttk-dtabf.
          MODIFY cha_shipments_at_save-new_vttk
                        FROM wa_vttk INDEX sy-tabix.
          RAISE error_with_message.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDLOOP.
  CLEAR wa_vttk.
  READ TABLE cha_shipments_at_save-new_vttk
                INTO wa_vttk INDEX 1.
  IF sy-subrc EQ 0.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = w_fwdagent
      IMPORTING
        output = w_fwdagent.
    IF NOT w_extid IS INITIAL.
      wa_vttk-exti1 = w_extid.
      CLEAR w_extid.
    ENDIF.
      MODIFY cha_shipments_at_save-new_vttk
                FROM wa_vttk INDEX 1.
  ENDIF.

Similar Messages

  • How to append the declaration tags to generated xml using Xquery

    Hi,
      How to append the declaration tags to generated xml using Xquery.generated XML is like
    <ROOT>
      <CHILD1></CHILD1>
      <CHILD2></CHILD2>
    </ROOT>
    Here I want to append the <?xml version="1.0" encoding="ISO-8859-1"?> and the result xml should be
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <ROOT>
      <CHILD1></CHILD1>
      <CHILD2></CHILD2>
    </ROOT>
    Can anybody help to do this.
    Thanks
    Mani

    First assign this element to a temp variable
    <ROOT>
      <CHILD1></CHILD1>
      <CHILD2></CHILD2>
    </ROOT>
    Now in XQuery expression create a new variable
    <?xml version="1.0" encoding="ISO-8859-1"?>
    $temp

  • How to create the Declarative Component?

    Hi,
    I am using jdev 11g Release 2.
    I want to create reusable component. So I want to create a declarative component.
    Please let me know some sample and study materials.
    Regards,
    Ragu

    another examples can be found in these links:
    Missing In or Out Parameter at Index 1
    http://andrejusb.blogspot.com/2009/10/custom-declarative-components-in-adf.html
    http://download.oracle.com/docs/cd/E17904_01/web.1111/b31973/af_reuse.htm#CACBFGFC

  • How can I will declare the symbol u2018 (Single Quote) in the report

    Hi ,
    Could you please tell me how can I will declare the symbol u2018 (Single Quote) in the report.
    My requirement is that I have concate the data with single quote and after that I have to store the data in to an internal table and I have to download the data in the form text file in the presentation server.
    For example :
    Let the below data I want to download into the presentation serve in the format of text file by storing in internal table.
    Assume all are constants:
    1st line : abcu2019add
    2nd line :  defu2019gef
    Thanks in advance.

    Hi Jyothi,
    Thanks for the quick reply .
    I can agree with you are point but My requirement is like this I am explaining clearly.
    I have declared the internal table like this.
    DATA: BEGIN OF OTAB OCCURS 0,
             LINE (9024),
           END OF OTAB.
    So I have to append the each line item into the internal table.
    So I am explaining what the data I have to append
    Ist line contains
    'UNBUNOC:2020308u2019 where 020308 I will get the  date from reguh table
    2nd line contains:
    'DTM+20020510' where the 20020510 will be reference document number from the table reguh.
    So I want to declare a constant 'UNBUNOC:2
    2nd the date from reguh table
    And another constant u2018
    So that I can concate all the three and I can put into string and I will append into internal table and I can download the data into the presentation server.
    Please let me know if you need any more clarification regarding my requirement.
    Thanks in advance.

  • How to use the method "getChildrenRemoved()" declared in ElementChange?

    How to use the method "getChildrenRemoved()" declared in DocumentEvent.ElementChange?

    I have tried to use it,but the code below alway say "Yes"....
    I really have no ideas about why ec is always a null.
    public void removeUpdate(DocumentEvent ee) {
           DocumentEvent.ElementChange ec = ee.getChange(doc.getDefaultRootElement());
           if(ec == null)
              System.out.println("Yes");
                     }

  • How to use the types declarations in smartforms

    hai
      already i declared the types in smartfomr global defination, how to call the types to the internal table and workarea, in which please i declare the internal table and work area by using the types structures
    for example
    types: begin of ty_kna1,
              kunnr type kunnr,
              name1 type name1,
              land1 type land1,
             end of ty_kna1.
    how to call the above types to internal table and work area in simartforms , in which place i declare the above types to the internal table and workarea

    Hi,
    Please see below
    **In Types tab
    types: begin of ty_kna1,
    kunnr type kunnr,
    name1 type name1,
    land1 type land1,
    end of ty_kna1.
    Types:ty_t_kna1 type standard table of ty_kna1.
    In Global data tab
    ***Internal table declaration
    data:i_kna1 type ty_t_kna1.
    ***Work area declaration
    data:wa_kna1 type ty_kna1.
    Regards
    Jana

  • How to remove the standalone="yes" attribute in the xml declaration?

    Hi,
    I am using JAXB 2.0 to generate XML files. Can anyone tell me how to remove the standalone="yes" attribute in the xml declaration? Thanks in advance.
    -Joey

    Just open the file with your favorite text program and type away. If you get a permissions problem (file is locked by...) then just stop tomcat and open/edit/save the file and restart tomcat.
    I also think that the admin context that comes with tomcat might allow you to modify/add/edit your users (not sure though)

  • How to specify the XML Declaration for an XML variable

    I need to set the XML declaration for my XML variable as
    follows:
    var employees:XML =
    <?xml version="1.0" encoding="utf-8"?>
    <employees>
    <employee ssn="123-123-1234">
    <name first="John" last="Doe"/>
    <address>
    <street>11 Main St.</street>
    <city>San Francisco</city>
    <state>CA</state>
    <zip>98765</zip>
    </address>
    </employee>
    <employee ssn="789-789-7890">
    <name first="Mary" last="Roe"/>
    <address>
    <street>99 Broad St.</street>
    <city>Newton</city>
    <state>MA</state>
    <zip>01234</zip>
    </address>
    </employee>
    </employees>;
    However, if I specify <?xml version="1.0"
    encoding="utf-8"?>, I get a design time and compile error. If I
    remove it it works fine. But the server to which I send this XML is
    expecting the declaration. Can somebody help me with this?
    Thanks

    I work mostly with the Java versions of the parser so you'll have to make the translation to C++. As far as I know, you can't use the SAX API to access to the encoding.
    You need to use the DOM along with Oracle's extension to the basic DOM functionality. Oracle's package, oracle.xml.parser.v2 defines a class which implements the Document interface called XMLDocument. This class has a method, getEncoding(), which returns the encoding. You would use the method in getDocument() in the Parser base class inherited by DOMParser to retrive the XMLDocument.
    Jeff

  • How to view the returned data from a stored procedure in TOAD?

    Hi,
    I created ref cursor in the stored procedure to return data. The stored procedure works fine, just want to view the result in TOAD. The BEGIN... EXEC... END can execute the stored procedure, but how to make the result display?
    Thanks!

    Right click the editor and choose
    "Prompt For Substitution Variables".
    Run for example the following code:
    DECLARE
    PROCEDURE p (cur OUT sys_refcursor)
    AS
    BEGIN
    OPEN cur FOR
    SELECT *
    FROM DUAL;
    END p;
    BEGIN
    p (:cur);
    END;
    The result will display in Toad's Data Grid!
    Regards Michael

  • How to avoid the duplicate values, I do not want the duplicate............

    i have one database table called "sms1" that table is updated every day or on daily basis it has the following fields in it:
    SQL> desc sms1;
    Name Null? Type
    MOBILE NUMBER
    RCSTCNATCNATCNATCNAWTHER VARCHAR2(39 CHAR)
    SNO NUMBER
    INDATE DATE
    From this table the is one column "RCSTCNATCNATCNATCNAWTHER VARCHAR2(39 CHAR)" . I am splitting it into different columns like :
    SQL> desc smssplit;
    Name Null? Type
    R VARCHAR2(2 CHAR)
    C VARCHAR2(2 CHAR)
    S VARCHAR2(1 CHAR)
    TC VARCHAR2(3 CHAR)
    NA VARCHAR2(3 CHAR)
    TC2 VARCHAR2(3 CHAR)
    NA2 VARCHAR2(3 CHAR)
    TC3 VARCHAR2(3 CHAR)
    NA3 VARCHAR2(3 CHAR)
    TC4 VARCHAR2(3 CHAR)
    NA4 VARCHAR2(3 CHAR)
    WTHER VARCHAR2(10 CHAR)
    SNO NUMBER
    INSERTDATA VARCHAR2(25 CHAR)
    Now I am written a procedure to insert the data from "Sms1" table to smssplit table...
    CREATE OR REPLACE PROCEDURE SPLITSMS
    AS
    BEGIN
    INSERT INTO scott.SMSSPLIT ( R,C,S,TC,NA,TC2,NA2,TC3,NA3,TC4,NA4,WTHER,SNO)
    SELECT SUBSTR(RCSTCNATCNATCNATCNAWTHER,1,2) R,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,3,2) C,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,5,1) S,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,6,3) TC,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,9,3) NA,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,12,3) TC2,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,15,3) NA2,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,18,3) TC3,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,21,3) NA3,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,24,3) TC4,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,27,3) NA4,
    SUBSTR(RCSTCNATCNATCNATCNAWTHER,30,10) WTHER, SNO
    FROM scott.SMS1 where SNO=(select MAX (sno) from SMS1);
    END;
    Now in order to update the second table with data from first table on regular basis I have written a job scheduler and I am using oracle 9.0. version...
    DECLARE
    X NUMBER;
    JobNumber NUMBER;
    BEGIN
    SYS.DBMS_JOB.SUBMIT
    job => X
    ,what => 'scott.SPLITSMS;'
    ,next_date => SYSDATE+1/1440
    ,interval => 'SYSDATE+1/1440 '
    ,no_parse => FALSE
    :JobNumber := to_char(X);
    END;
    Now this job scheduler is working properly and updating the data for every one minute but it is taking or updating the duplicate values also ..like example:
    R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
    INSERTDATA
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:49:16
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:49:16
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:50:17
    R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
    INSERTDATA
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:50:17
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:51:19
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:51:19
    R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
    INSERTDATA
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:52:20
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:52:20
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:53:22
    R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
    INSERTDATA
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:53:22
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:54:45
    33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
    06-SEP-2012 03:54:45
    Now I do not want the duplicate values to be updated ...and want them to ignore them.....
    please I need a help on this query........How to avoid the duplicate values............

    Look at the posts closely:might not be needed if formatted ;)
    create or replace procedure splitsms as
    begin
      insert into scott.smssplit (r,c,s,tc,na,tc2,na2,tc3,na3,tc4,na4,wther,sno)
      select substr(rcstcnatcnatcnatcnawther,1,2) r,
             substr(rcstcnatcnatcnatcnawther,3,2) c,
             substr(rcstcnatcnatcnatcnawther,5,1) s,
             substr(rcstcnatcnatcnatcnawther,6,3) tc,
             substr(rcstcnatcnatcnatcnawther,9,3) na,
             substr(rcstcnatcnatcnatcnawther,12,3) tc2,
             substr(rcstcnatcnatcnatcnawther,15,3) na2,
             substr(rcstcnatcnatcnatcnawther,18,3) tc3,
             substr(rcstcnatcnatcnatcnawther,21,3) na3,
             substr(rcstcnatcnatcnatcnawther,24,3) tc4,
             substr(rcstcnatcnatcnatcnawther,27,3) na4,
             substr(rcstcnatcnatcnatcnawther,30,10) wther,
             sno
        from scott.sms1 a
       where sno = (select max(sno)
                      from sms1
                     where sno != a.sno
                   ); ---------------> added where clause with table alias.
    end;Regards
    Etbin

  • How to change the default orientation?

    Hello,
         I'm new to Adobe Flash Builder and I am currently making a mobile application for a school project. I was wondering how you change the default app orientation to landscape. I've tried going into my app.xml and change the aspect ratio to landscape with no luck, and it is very hard to find any answers on the internet. I would greatly appreciate your help.
    HomeView.mxml Code:
    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:s="library://ns.adobe.com/flex/spark"
                        actionBarVisible="false" tabBarVisible="false" title="HomeView">
              <fx:Declarations>
              </fx:Declarations>
              <s:Image left="0" right="0" top="0" bottom="0" scaleMode="zoom" smooth="true"
                                   smoothingQuality="high" source="@Embed('file:///C:/Users/Owner/Downloads/48127-solarsystem-teaser.jpg')"/>
              <s:Button x="-5" y="0" width="410" height="1504"
                                    skinClass="spark.skins.mobile.TransparentNavigationButtonSkin" click="navigator.pushView(Sun)"/>
              <s:Button x="444" y="852" width="80" height="80"
                                    skinClass="spark.skins.mobile.TransparentNavigationButtonSkin" click="navigator.pushView(Mercury)"/>
              <s:Button x="628" y="742" width="120" height="124"
                                    skinClass="spark.skins.mobile.TransparentNavigationButtonSkin" click="navigator.pushView(Venus)"/>
              <s:Button x="836" y="632" width="127" height="117"
                                    skinClass="spark.skins.mobile.TransparentNavigationButtonSkin" click="navigator.pushView(Earth)"/>
              <s:Button x="994" y="506" width="99" height="96"
                                    skinClass="spark.skins.mobile.TransparentNavigationButtonSkin" click="navigator.pushView(Mars)"/>
              <s:Button x="1255" y="464" width="298" height="279"
                                    skinClass="spark.skins.mobile.TransparentNavigationButtonSkin" click="navigator.pushView(Jupiter)"/>
              <s:Button x="1626" y="302" width="274" height="270"
                                    skinClass="spark.skins.mobile.TransparentNavigationButtonSkin" click="navigator.pushView(Saturn)"/>
              <s:Button x="1965" y="196" width="175" height="174"
                                    skinClass="spark.skins.mobile.TransparentNavigationButtonSkin" click="navigator.pushView(Uranus)"/>
              <s:Button x="2201" y="66" width="175" height="174"
                                    skinClass="spark.skins.mobile.TransparentNavigationButtonSkin" click="navigator.pushView(Neptune)"/>
    </s:View>
    App.xml code:
    <!-- The initial aspect ratio of the app when launched (either "portrait" or "landscape").
                                  Optional. Mobile only. Default is the natural orientation of the device -->
                        <!-- <aspectRatio>landscape</aspectRatio> -->
                        <!-- Whether the app will begin auto-orienting on launch. Optional. Mobile
                                  only. Default false -->
                        <!-- <autoOrients>false</autoOrients> -->
    I need to make it so that the app is permanently in landscape.
    Thanks again.
         8th grade student

    <!-- <aspectRatio>landscape</aspectRatio> -->
    <!-- <autoOrients>false</autoOrients> -->
    In XML, everything within <!-- and --> is a comment.  You need to remove the <!-- and -->:
    <aspectRatio>landscape</aspectRatio>
    <autoOrients>false</autoOrients>

  • How to change the default element tag using dbms_xmlgen

    here is my code that generate output for purchase order data. I followed the syntax shown in xml db developer guide.
    I am getting the results but element tags are CAPS letters( As the coloumn names in the type defenitions are stored in CAPS in Oracle). but I need to show in small letters as per my requirement.
    can anyone help me how to change the default tag names for elements.
    ==================================HERE IS THE CODE==================
    DECLARE
    qryCtx DBMS_XMLGEN.ctxHandle;
    result CLOB;
    BEGIN
    qryCtx := DBMS_XMLGEN.newContext
    ('SELECT PODL_H_T
    ( CLOSEDDATETIME ,
    COMPANY ,
    CAST(MULTISET
    (SELECT LINENUMBER ,
    COMPANY ,
    PURCHASEORDERID ,
    ITEM ,
    QUANTITYUM ,
    TOTALQUANTITY
    FROM cpo_wms_podl_LINES
    WHERE PURCHASEORDERID = PH.PURCHASEORDERID) as PurchaseOrderDetailList
    FROM cpo_wms_podl_HEADERS PH ');
    -- now get the result
    DBMS_XMLGEN.setRowSetTag(qryCtx, 'Receipts' );
    DBMS_XMLGEN.setRowTag(qryCtx, 'PurchaseOrder' );
    result := DBMS_XMLGEN.getXML(qryCtx);
    INSERT INTO temp_clob_tab VALUES (result);
    DBMS_XMLGEN.closeContext(qryCtx);
    END;
    -- select * from temp_clob_tab
    ===========create type script=====================
    cpo_wms_podl_HEADERS
    CREATE or replace TYPE PurchaseOrderDetail AS OBJECT(
    LINENUMBER VARCHAR2(400 BYTE),
    COMPANY VARCHAR2(400 BYTE),
    PURCHASEORDERID VARCHAR2(400 BYTE),
    ITEM VARCHAR2(400 BYTE),
    QUANTITYUM VARCHAR2(400 BYTE),
    TOTALQUANTITY NUMBER
    create type PurchaseOrderDetailList as table of PurchaseOrderDetail
    create table temp_clob_tab(result CLOB)
    create type podl_HEADERS_list_t as table of podl_HEADERS_t
    CREATE or replace TYPE PODL_H_T AS OBJECT
    CLOSEDDATETIME DATE,
    COMPANY VARCHAR2(400 BYTE),
    CREATEDDATETIME DATE,
    PURCHASEORDERID VARCHAR2(400 BYTE),
    SHIP_TO VARCHAR2(400 BYTE),
    linelist PurchaseOrderDetailList
    )

    but I need to show in small letters as per my requirement.add alias column names in double quotes as in
    SQL> select dbms_xmlgen.getxmltype('select dname "DeptName", loc "Location" from dept') dept_xml from dual
    DEPT_XML                                                                       
    <ROWSET>                                                                       
      <ROW>                                                                        
        <DeptName>ACCOUNTING</DeptName>                                            
        <Location>NEW YORK</Location>                                              
      </ROW>                                                                       
      <ROW>                                                                        
        <DeptName>RESEARCH</DeptName>                                              
        <Location>DALLAS</Location>                                                
      </ROW>                                                                       
      <ROW>                                                                        
        <DeptName>SALES</DeptName>                                                 
        <Location>CHICAGO</Location>                                               
      </ROW>                                                                       
      <ROW>                                                                        
        <DeptName>OPERATIONS</DeptName>                                            
        <Location>BOSTON</Location>                                                
      </ROW>                                                                       
      <ROW>                                                                        
        <DeptName>SALES</DeptName>                                                 
        <Location>MUNICH</Location>                                                
      </ROW>                                                                       
    </ROWSET>                                                                      
    1 row selected.

  • How to bring the data from application server to presentation server

    hi,
    i have one problem,i have written the program which will open the files in the application server when we run the program in the background(sm37),the same data from application server i want to bring into presentation server in the format of (.csv),how to bring the data from application to presentation server can any body help me on this  topic.folowing is the code .
    *& Report  ZPFA_HIER_LOAD
    REPORT  ZFPA_HIER_LOAD.
    *---- Declaration of Oracle connectioN
    DATA con_name LIKE dbcon-con_name VALUE 'COMSHARE'.
    DATA: MFL1(9),MFL2(5),MFL3(9),MFL4(2),MFL5(8) TYPE c.
    DATA : mfilename type string.
    data: begin of matab1 occurs 0,
          MFL1(9) TYPE C,
          MFL2(5) TYPE C,
          MFL3(9) TYPE C,
          MFL4(2) TYPE C,
          MFL5(8) TYPE C  ,
         end of matab1 .
    data: setid(8) type c.
    data: begin of source occurs 0,
          setid(8) type c,
          end of source.
    *PARAMETERS : p_pfile LIKE filename-FILEEXTERN.
    *PARAMETERS : m_bsenty(8). " type c obligatory.
    *mfilename = P_PFILE.
    EXEC SQL.
      SET CONNECTION :con_name
    ENDEXEC.
    EXEC SQL.
      CONNECT TO :con_name
    ENDEXEC.
    EXEC SQL PERFORMING get_source.
      SELECT set_id FROM UNIT_SET INTO
      :setid
      ORDER BY SET_ID
    ENDEXEC.
    start-of-selection.
    LOOP AT SOURCE.
      REFRESH matab1. CLEAR matab1.
      EXEC SQL PERFORMING evaluate.
    SELECT TO_CHAR(MEM_ID),TRIM(TO_CHAR(MEM_PID)) FROM UNIT_TREE INTO :MFL1,
    :MFL5
    where set_id = :SOURCE-SETID ORDER BY MEM_ID
      ENDEXEC.
      if SOURCE-SETID = '80000000'.
       mfilename = '/tmp/aesorg'.
      elseif SOURCE-SETID = '80000006'.
       mfilename = '/tmp/Consolidation_Manager'.
      elseif SOURCE-SETID = '80000010'.
       mfilename = '/tmp/10org'.
      elseif SOURCE-SETID = '80000012'.
       mfilename = '/tmp/20org'.
      elseif SOURCE-SETID = '80000018'.
       mfilename = '/tmp/30org'.
      elseif SOURCE-SETID = '80000025'.
       mfilename = '/tmp/40org'.
      Endif.
      mfilename = '/usr/test.dat'.
    ************************This was i tried***********************
      open dataset mfilename for output in text mode encoding default." IN
    *TEXT MODE ENCODING DEFAULT.
    if sy-subrc <> 0.
    exit.
    endif.
    close dataset mfilename.
    CALL FUNCTION 'GUI_DOWNLOAD'
       EXPORTING
         FILENAME         = MFILENAME
         FILETYPE         = 'ASC'
       TABLES
         data_tab         = matab1
       EXCEPTIONS
         file_write_error = 1
         invalid_type     = 2
         no_authority     = 3
         unknown_error    = 4
         OTHERS           = 10.
    loop at matab1 .
    transfer matab1 to mfilename.
    endloop.
      clear matab1.
    ENDLOOP.
    loop at matab1 .
    transfer matab1 to mfilename.
    endloop.
    close dataset mfilename.
         MFL5 = '0'.
       CLEAR MFL5.
    FORM evaluate.
      if MFL5 = -1.
        MFL5 = ''.
      ENDIF.
      concatenate MFL1 ','   into MFL1.
      concatenate MFL1 ','   into MFL3.
      matab1-MFL1 = MFL1.
      matab1-MFL2 = 'ZBUE,'.
      matab1-MFL3 = MFL3.
      matab1-MFL4 = ' ,'.
      matab1-MFL5 = MFL5.
      append matab1 .
      CLEAR MFL1.
      CLEAR MFL2.
      CLEAR MFL3.
      CLEAR MFL4.
      CLEAR MFL5.
    ENDFORM.
                     "evaluate
    *&      Form  GET_SOURCE
          text
    FORM GET_SOURCE.
      source-setid = setid.
      append source.
      clear source.
    ENDFORM.                    "GET_SOURCE

    Hi Rammohan,
    You cannot use OPEN DATASET to transfer data from application server to presentation server.
    You can do the following :
    <b>Do 1st point in BACKGROUND</b>
    1. Read the data file from application server into an internal table using OPEN DATASET
    <b>Do 2nd point in Foreground</b>
    2. Once you get the data into an internal table, then use FM GUI_DOWNLOAD to download it on presentation server
    You cannot use the above 2 point together in Background because its not possible. Hence you need program it partially in background and partially in foreground.
    Best regards,
    Prashant

  • How to improve the performance of this code

    Hi gurus
    code is given below with LDB
    this code look big but most of lines are commented
    plz help its urgent
    thanks in advance
    *& Report  ZSALES_RECON
    REPORT  ZSALES_RECON.
    TYPE-POOLS : SLIS.
    nodes: bseg , bkpf.
    data : begin of zbseg occurs 0,
    kunnr like bseg-kunnr,
    *lifnr like bseg-lifnr,
    dmbtr like bseg-dmbtr,
    *shkzg like bseg-shkzg,
    *gsber like bseg-gsber,
    bschl like bseg-bschl,
    *sgtxt like bseg-sgtxt,
    total like bseg-dmbtr,
    hkont like bseg-hkont,
    BUDAT LIKE Bkpf-BUDAT,
    belnr LIKE BSEG-belnr,
    cash like bseg-dmbtr,
    credit like bseg-dmbtr,
    abn_voucher like bseg-dmbtr,
    barista_voucher like bseg-dmbtr,
    accor like bseg-dmbtr,
    sodexho like bseg-dmbtr,
    gift like bseg-dmbtr,
    corp like bseg-dmbtr,
    card like bseg-dmbtr,
    miscellaneous like bseg-dmbtr,
    werks like bseg-werks,
    gjahr like bseg-gjahr,
    SR_NO TYPE I,
    shkzg like bseg-shkzg,
          end of zbseg,
          TP_TBL_DATA like ZBSEG.
        DATA  : idx TYPE sy-tabix.
    Report data to be shown.
    data: it_data like ZBSEG.
    Heading of the report.
    data: t_heading type slis_t_listheader.
    AT SELECTION-SCREEN.
    get bkpf.
    START-OF-SELECTION.
    data : sum_mis like bseg-dmbtr,
           sum_abn like bseg-dmbtr,
           sum_cash like bseg-dmbtr,
           sum_credit like bseg-dmbtr,
           sum_card like bseg-dmbtr,
           sum_barista_voucher like bseg-dmbtr,
           sum_accor like bseg-dmbtr,
           sum_sodexho like bseg-dmbtr,
           sum_gift like bseg-dmbtr,
           sum_corp like bseg-dmbtr.
    data : wa1_total like bseg-dmbtr.
    data : wa_belnr like bseg-belnr,
           wa_kunnr like bseg-kunnr,
           wa_werks like bseg-werks,
           belnr1 like bseg-belnr,
           wa_sr_no type i.
    GET BSEG.
    data : wa like line of zbseg.
    data : count type i,
           count1 type i.
    move-corresponding bseg to zbseg.
    *idx = sy-tabix.
    on change of zbseg-belnr.
    wa_kunnr = zbseg-kunnr.
    wa_kunnr = wa_kunnr+6(4).
    select single werks into wa_werks from bseg where belnr = zbseg-belnr
    and kunnr = '' and gjahr = zbseg-gjahr.
    if wa_kunnr = wa_werks.
    if zbseg-bschl <> '01'.
    clear: sum_mis,wa1_total,sum_abn,sum_cash,sum_credit,sum_card,
    sum_barista_voucher,sum_accor,sum_sodexho,sum_gift,sum_corp.
    wa-BUDAT = BKPF-BUDAT.
    wa-bschl = zbseg-bschl.
    wa-hkont = zbseg-hkont.
    wa-belnr = zbseg-belnr.
    wa_belnr = wa-belnr.
    wa-shkzg = zbseg-shkzg.
    wa-kunnr = zbseg-kunnr.
    count = wa-sr_no.
    *wa-sr_no = count + 1.
    idx = idx + 1.
    append wa to zbseg.
    **count = wa-sr_no.
    *wa-sr_no = wa-sr_no + 1.
    clear wa-total.
    endif.
    endif.
    endon.
    *clear : wa1_total.
    if wa_belnr = zbseg-belnr.
    loop at zbseg into wa.
    wa-total = wa1_total.
    wa-bschl = zbseg-bschl.
    wa-hkont = zbseg-hkont.
    count = sy-tabix.
    wa-sr_no = count.
    count1 = count.
    *wa_sr_no = count.
    modify zbseg from wa transporting sr_no.
    IF wa-bschl eq  '40' and wa-hkont eq '0024013020'.
    if sy-tabix = 1.
    wa-cash  = zbseg-dmbtr.
    sum_cash = sum_cash + wa-cash.
    wa-cash = sum_cash.
    modify zbseg index idx from wa transporting cash.
    endif.
    endif.
    IF wa-bschl eq  '40' and wa-hkont eq '0026060010'.
       if sy-tabix = 1.
    wa-credit  = zbseg-dmbtr.
    sum_credit = sum_credit + wa-credit.
    wa-credit = sum_credit.
    modify zbseg index idx from wa transporting credit.
    endif.
    endif.
    IF wa-bschl eq  '40' and wa-hkont eq '0026060015'.
    if sy-tabix = 1.
    wa-abn_voucher  = zbseg-dmbtr.
    sum_abn = sum_abn + wa-abn_voucher.
    wa-abn_voucher = sum_abn.
    modify zbseg index idx from wa transporting abn_voucher.
    endif.
    endif.
    IF wa-bschl eq  '40' and wa-hkont eq '0026060017'.
    if sy-tabix = 1.
    wa-barista_voucher  = zbseg-dmbtr.
    sum_barista_voucher = sum_barista_voucher + wa-barista_voucher.
    wa-barista_voucher = sum_barista_voucher.
    modify zbseg  index idx from wa transporting barista_voucher.
    endif.
    endif.
    IF wa-bschl eq  '40' and wa-hkont eq '0026060020'.
    if sy-tabix = 1.
    wa-sodexho  = zbseg-dmbtr.
    sum_sodexho = sum_sodexho + wa-sodexho.
    wa-sodexho = sum_sodexho.
    modify zbseg index idx from wa transporting sodexho.
    endif.
    endif.
    IF wa-bschl eq  '40' AND  wa-hkont eq '0026060030'.
    if sy-tabix = 1.
    wa-accor  = zbseg-dmbtr.
    sum_accor = sum_accor + wa-accor.
    wa-accor = sum_accor.
    modify zbseg  index idx from wa transporting accor.
    endif.
    endif.
    IF wa-bschl eq  '40' AND  wa-hkont eq '0026070040'.
    if sy-tabix = 1.
    wa-gift  = zbseg-dmbtr.
    sum_gift = sum_gift + wa-gift.
    wa-gift = sum_gift.
    modify zbseg index idx from wa transporting gift.
    endif.
    endif.
    IF wa-bschl eq  '40' AND  wa-hkont eq '0026060070'.
    if sy-tabix = 1.
    wa-card  = zbseg-dmbtr.
    sum_card = sum_card + wa-card.
    wa-card = sum_card.
    modify zbseg index idx from wa transporting card.
    endif.
    endif.
    IF wa-bschl eq  '40' AND  wa-hkont eq '0026060018'.
    if sy-tabix = 1.
    wa-corp  = zbseg-dmbtr.
    sum_corp = sum_corp + wa-corp.
    wa-corp = sum_corp.
    modify zbseg index idx from wa transporting corp.
    endif.
    endif.
    *IF wa-bschl eq  '11' .
    *wa-total  = zbseg-dmbtr.
    *modify zbseg index idx from wa transporting total.
    *endif.
    IF wa-bschl EQ  '40'  or wa-bschl = '01' .
    if sy-tabix = 1.
    wa-total = zbseg-dmbtr.
    wa1_total = wa1_total + wa-total.
    wa-total = wa1_total.
    *if idx = 2.
    *modify zbseg index 1 from wa transporting total.
    *else.
    modify zbseg  index idx from wa transporting total.
    *endif.
    endif.
    endif.
    *IF zbseg-TOTAL NE zbseg-DMBTR.
    IF wa-BSCHL NE '11' AND wa-BSCHL NE '40'. "AND wa-BSCHL NE '01'.
    if sy-tabix = 1.
    if wa-shkzg = 'S'.
    wa-miscellaneous = - wa-miscellaneous.
    endif.
    wa-miscellaneous =  ZBSEG-DMBTR.
    sum_mis = sum_mis + wa-miscellaneous.
    wa-miscellaneous = sum_mis.
    modify zbseg index idx from wa transporting miscellaneous.
    endif.
    ENDIF.
    *wa1-miscellaneous = wa-miscellaneous.
    *modify zbseg index idx from wa.
    *ENDIF.
    *append wa to zbseg.
    *clear:zbseg-dmbtr.
    endloop.
    endif.
    *****endif.
    *****endon.
    *ENDFORM.
    *append zbseg.
    *endloop.
    End-of-selection.
      perform build_alv using zbseg t_heading.
    *&      Form  build_alv
          Builds and display the ALV Grid.
    form build_alv using t_data
    *tp_tbl_data
                         t_heading  type slis_t_listheader.
    ALV required data objects.
    data: w_title   type lvc_title,
          w_repid   type syrepid,
          w_comm    type slis_formname,
          w_status  type slis_formname,
          x_layout  type slis_layout_alv,
          t_event    type slis_t_event,
          t_fieldcat type slis_t_fieldcat_alv,
          t_sort     type slis_t_sortinfo_alv.
    refresh t_fieldcat.
    refresh t_event.
    refresh t_sort.
    clear x_layout.
    clear w_title.
    Field Catalog
      perform set_fieldcat2 using:
    1 'SR_NO' 'SR_NO' 'BKPF' '5' space  space  'SR NO'  space  space space
    space space space space space t_fieldcat ,
    2 'BELNR' 'BELNR' 'BKPF' '10' space  space  'Document No'  space  space
    space space space space space space t_fieldcat ,
    3 'BUDAT' 'BUDAT' 'BKPF' '10' space  space  'Document Date'  space
    space space space space space space space t_fieldcat ,
    4 'KUNNR' space space  space space  space  'Site'  space  space
    space space space space space space t_fieldcat ,
    5 'TOTAL' space 'BSEG' space space  space  'Total'  space  space space
    space space space space 'X' t_fieldcat ,
    6 'CASH' 'CASH' 'BSEG' space space  space  'Cash Sales'
      space  space space space space space space 'X' t_fieldcat ,
    7 'CREDIT' 'CREDIT' 'BSEG' space space  space  'Credit Card'
    space space space space space space space 'X' t_fieldcat ,
    8 'ABN_VOUCHER' space 'BSEG' space space  space  'ABN Voucher'  space
    space
    space space space space space 'X' t_fieldcat ,
    9 'BARISTA_VOUCHER' space 'BSEG' '15' space  space  'BARISTA Voucher'
    space  space
    space space space space space 'X' t_fieldcat ,
    10 'CORP' 'CORP' 'BSEG' space space  space  'ABN Corp'  space  space
    space space space space space 'X' t_fieldcat ,
    11 'SODEXHO' 'SODEXHO' 'BSEG' space space  space  'Sodexho'  space
    space space space space space space 'X' t_fieldcat ,
    12 'ACCOR' 'ACCOR' 'BSEG' space space  space  'Accor'
    space  space space space space space space 'X' t_fieldcat ,
    13 'GIFT' 'GIFT' 'BSEG' space space  space  'Gift Coupon'
    space  space space space space space space 'X' t_fieldcat ,
    14 'CARD' 'CARD' 'BSEG' space space  space  'Diners Card'  space
    space space space space space space 'X' t_fieldcat ,
    15 'MISCELLANEOUS' space 'BKPF' '18' space  space
    'Miscellaneous Income' space space space space space space space 'X'
    t_fieldcat .
    *14 'KBETR' 'KBETR' 'KONP' '10' space  space  'Tax %age'  space  space
    *space space space space space space t_fieldcat ,
    *15 'MWSKZ1' 'MWSKZ1' 'RBKP' space space  space  'Tax Type'  space
    *space
    space space space space space space t_fieldcat ,
    *16 'AMT' 'AMT' 'RBKP' space space  space  'Amount Payable'  space
    *space
    space space space space space 'X' t_fieldcat ,
    *17 'WERKS' 'SITE' 'RSEG' space space  space  'State'  space  space
    *space space space space space space t_fieldcat .
    *18 'GSBER' 'GSBER' 'RBKP' space space  space  'Business Area'  space
    *space space space space space space space t_fieldcat .
    Layout
    x_layout-zebra = 'X'.
    Top of page heading
      perform set_top_page_heading using t_heading t_event.
    Events
      perform set_events using t_event.
    GUI Status
      w_status = ''.
      w_repid = sy-repid.
    Title
    w_title = <<If you want to set a title for
                the ALV, please, uncomment and edit this line>>.
    User commands
      w_comm   = 'USER_COMMAND'.
    Order
    Example
    PERFORM set_order USING '<field>' 'IT_DATA' 'X' space space t_sort.
    Displays the ALV grid
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program       = w_repid
          it_fieldcat              = t_fieldcat
          is_layout                = x_layout
          it_sort                  = t_sort
          i_callback_pf_status_set = w_status
          i_callback_user_command  = w_comm
          i_save                   = 'X'
          it_events                = t_event
          i_grid_title             = w_title
        tables
          t_outtab                 = zbseg
         t_data
        exceptions
          program_error            = 1
          others                   = 2.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " build_alv.
    *&      Form  set_top_page_heading
          Creates the report headings.
    form set_top_page_heading using t_heading type slis_t_listheader
                                    t_events  type slis_t_event.
    data: x_heading type slis_listheader,
          x_event   type line of slis_t_event.
    Report title
      clear t_heading[].
      clear x_heading.
      x_heading-typ = 'H'.
      x_heading-info = 'SALES RECONCILIATION REPORT'(001).
      append x_heading to t_heading.
    Top of page event
      x_event-name = slis_ev_top_of_page.
      x_event-form = 'TOP_OF_PAGE'.
      append x_event to t_events.
    endform.
    *&      Form  set_events
          Sets the events for ALV.
          The TOP_OF_PAGE event is alredy being registered in
          the set_top_page_heading subroutine.
    form set_events using t_events type slis_t_event.
    data: x_event   type line of slis_t_event.
    Example
    clear x_event.
    x_event-name = .
    x_event-form = .
    append x_event to t_event.
    endform.
    *&      Form  set_order
          Adds an entry to the order table.
    FORM set_order USING p_fieldname p_tabname p_up p_down p_subtot
                         t_sort TYPE slis_t_sortinfo_alv.
      DATA: x_sort TYPE slis_sortinfo_alv.
      CLEAR x_sort.
      x_sort-fieldname = p_fieldname.
      x_sort-tabname   = p_tabname.
      x_sort-up = p_up.
      x_sort-down = p_down.
      x_sort-subtot = p_subtot.
      APPEND x_sort TO t_sort.
    ENDFORM.                    "set_order
    *&      Form  set_fieldcat2
          Adds an entry to the field catalog.
       p_colpos: Column position.
       p_fieldname: Field of internal table which is being described by
    *            this record of the field catalog.
       p_ref_fieldname: (Optional) Table field / data element which
    *                describes the properties of the field.
    *                If this field is not given, it is copied from
    *                the fieldname.
       p_ref_tabname: (Optional) Table which holds the field referenced
    *              by <<p_ref_fieldname>>.
                      If this is not given, the parameter
                      <<p_ref_fieldname>> references a data element.
       p_outputlen: (Optional) Column width.
       p_noout: (Optional) If set to 'X', states that the field is not
    *           showed initially. If so, the field has to be
                included in the report at runtime using the display
                options.
       p_seltext_m: (Optional) Medium label to be used as column header.
       p_seltext_l: (Optional) Long label to be used as column header.
       p_seltext_s: (Optional) Small label to be used as column header.
       p_reptext_ddic: (Optional) Extra small (heading) label to be
    *                used as column header.
       p_ddictxt: (Optional) Set to 'L', 'M', 'S' or 'R' to select
                  whether to use SELTEXT_L, SELTEXT_M, SELTEXT_S,
                  or REPTEXT_DDIC as text for column header.
       p_hotspot: (Optional) If set to 'X', this field will be used
    *             as a hotspot area for cursor, alolowing the user
    *          to click on the field.
       p_showasicon: (Optional) If set to 'X', this field will be shown
                     as an icon and the contents of the field will set
    *             which icon to show.
       p_checkbox: (Optional) If set to 'X', this field will be shown
                   as a checkbox.
       p_edit: (Optional) If set to 'X', this field will be editable.
       p_dosum: (Optional) If set to 'X', this field will be summed
                (aggregation function) according to the grouping set
                by the order functions.
       t_fieldcat: Table which contains the whole fieldcat.
    FORM set_fieldcat2 USING
          p_colpos p_fieldname p_ref_fieldname p_ref_tabname
          p_outputlen p_noout
          p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
          p_hotspot p_showasicon p_checkbox p_edit
          p_dosum
          t_fieldcat TYPE slis_t_fieldcat_alv.
      DATA: wa_fieldcat TYPE slis_fieldcat_alv.
      CLEAR wa_fieldcat.
    General settings
      wa_fieldcat-fieldname = p_fieldname.
      wa_fieldcat-col_pos = p_colpos.
      wa_fieldcat-no_out = p_noout.
      wa_fieldcat-hotspot = p_hotspot.
      wa_fieldcat-checkbox = p_checkbox.
      wa_fieldcat-icon = p_showasicon.
      wa_fieldcat-do_sum = p_dosum.
    Set reference fieldname, tablenam and rollname.
    If p_ref_tabname is not given, the ref_fieldname given
       is a data element.
    If p_ref_tabname is given, the ref_fieldname given is a
       field of a table.
    In case ref_fieldname is not given,
       it is copied from the fieldname.
      IF p_ref_tabname IS INITIAL.
        wa_fieldcat-rollname =   p_ref_fieldname.
      ELSE.
        wa_fieldcat-ref_tabname = p_ref_tabname.
        IF p_ref_fieldname EQ space.
          wa_fieldcat-ref_fieldname =   wa_fieldcat-fieldname.
        ELSE.
          wa_fieldcat-ref_fieldname =   p_ref_fieldname.
        ENDIF.
      ENDIF.
    Set output length.
      IF NOT p_outputlen IS INITIAL.
        wa_fieldcat-outputlen = p_outputlen.
      ENDIF.
    Set text headers.
      IF NOT p_seltext_m IS INITIAL.
        wa_fieldcat-seltext_m = p_seltext_m.
      ENDIF.
      IF NOT p_seltext_l IS INITIAL.
        wa_fieldcat-seltext_l = p_seltext_l.
      ENDIF.
      IF NOT p_seltext_s IS INITIAL.
        wa_fieldcat-seltext_s = p_seltext_s.
      ENDIF.
      IF NOT p_reptext_ddic IS INITIAL.
        wa_fieldcat-reptext_ddic = p_reptext_ddic.
      ENDIF.
      IF NOT p_ddictxt IS INITIAL.
        wa_fieldcat-ddictxt = p_ddictxt.
      ENDIF.
    Set as editable or not.
      IF NOT p_edit IS INITIAL.
        wa_fieldcat-input     = 'X'.
        wa_fieldcat-edit     = 'X'.
      ENDIF.
      APPEND wa_fieldcat TO t_fieldcat.
    ENDFORM.                   "set_fieldcat2
    ======================== Subroutines called by ALV ================
    *&      Form  top_of_page
          Called on top_of_page ALV event.
          Prints the heading.
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
        i_logo             = <<If you want to set a logo, please,
                             uncomment and edit this line>>
          it_list_commentary = t_heading.
    endform.                    " alv_top_of_page
    *&      Form  user_command
          Called on user_command ALV event.
          Executes custom commands.
    form user_command using r_ucomm     like sy-ucomm
                            rs_selfield type slis_selfield.
    Example Code
    Executes a command considering the sy-ucomm.
    CASE r_ucomm.
       WHEN '&IC1'.
         Set your "double click action" response here.
         Example code: Create and display a status message.
         DATA: w_msg TYPE string,
               w_row(4) TYPE n.
         w_row = rs_selfield-tabindex.
         CONCATENATE 'You have clicked row' w_row
                     'field' rs_selfield-fieldname
                     'with value' rs_selfield-value
                     INTO w_msg SEPARATED BY space.
         MESSAGE w_msg TYPE 'S'.
    ENDCASE.
    End of example code.
    endform.                    "user_command
    *********************************ldb code start from here *************************************************************
         DATABASE PROGRAM OF LOGICAL DATABASE ZBRM_3
      top-include and nxxx-include are generated automatically
      Do NOT change their names manually!!!
    *include DBZBRM_3TOP . " header
    *include DBZBRM_3NXXX . " all system routines
    include DBZBRM_3F001 . " user defined include
    PROGRAM SAPDBZBRM_3 DEFINING DATABASE ZBRM_3.
    TABLES:
        BKPF,
        BSEG.
    Hilfsfelder
    DATA:
       BR_SBUKRS LIKE BKPF-BUKRS,
        BR_SBELNR LIKE BKPF-BELNR,
        BR_SGJAHR LIKE BKPF-GJAHR,
        BR_SBUDAT LIKE BKPF-BUDAT,
        BR_SGSBER LIKE BSEG-GSBER.
       BR_SBUZEI LIKE BSEG-BUZEI,
       BR_SEBELN LIKE BSEG-EBELN,
       BR_SEBELP LIKE BSEG-EBELP,
       BR_SZEKKN LIKE BSEG-ZEKKN.
    working areas for the authority check                     "n435991
    for the company code                                      "n435991
    *TYPES : BEGIN OF STYPE_BUKRS,                               "n435991
             BUKRS              LIKE  T001-BUKRS,              "n435991
             WAERS              LIKE  T001-WAERS,              "n435991
             RETCODE            TYPE  N,                       "n435991
           END OF STYPE_BUKRS.                                 "n435991
                                                               "n435991
    *DATA : G_S_BUKRS             TYPE  STYPE_BUKRS,             "n435991
          G_T_BUKRS             TYPE  STYPE_BUKRS   OCCURS 0.  "n435991
                                                               "n435991
    for the document type                                     "n435991
    *TYPES : BEGIN OF STYPE_BLART,                               "n435991
             BLART              LIKE  BKPF-BLART,              "n435991
             RETCODE            TYPE  N,                       "n435991
           END OF STYPE_BLART.                                 "n435991
                                                               "n435991
    *DATA : G_S_BLART             TYPE  STYPE_BLART,             "n435991
          G_T_BLART             TYPE  STYPE_BLART   OCCURS 0.  "n435991
                                                               "n435991
    for the business area                                     "n435991
    *TYPES : BEGIN OF STYPE_GSBER,                               "n435991
             GSBER              LIKE  BSEG-GSBER,              "n435991
             RETCODE            TYPE  N,                       "n435991
           END OF STYPE_GSBER.                                 "n435991
                                                               "n435991
    *DATA : G_S_GSBER             TYPE  STYPE_GSBER,             "n435991
          G_T_GSBER             TYPE  STYPE_GSBER   OCCURS 0.  "n435991
                                                               "n435991
    for the purchasing organization                           "n435991
    *TYPES : BEGIN OF STYPE_EKORG,                               "n435991
             EKORG              LIKE  EKKO-EKORG,              "n435991
             RETCODE            TYPE  N,                       "n435991
           END OF STYPE_EKORG.                                 "n435991
                                                               "n435991
    *DATA : G_S_EKORG             TYPE  STYPE_EKORG,             "n435991
          G_T_EKORG             TYPE  STYPE_EKORG   OCCURS 0.  "n435991
                                                               "n435991
    for the plant                                             "n435991
    *TYPES : BEGIN OF STYPE_WERKS,                               "n435991
             WERKS              LIKE  EKPO-WERKS,              "n435991
             RETCODE            TYPE  N,                       "n435991
           END OF STYPE_WERKS.                                 "n435991
                                                               "n435991
    *DATA : G_S_WERKS             TYPE  STYPE_WERKS,             "n435991
          G_T_WERKS             TYPE  STYPE_WERKS   OCCURS 0.  "n435991
                                                               "n435991
    *DATA : G_F_TABIX             LIKE   SY-TABIX.               "n435991
                                                               "n435991
    working tables for array database access                  "n934526
    *types : begin of stype_key,                                 "n934526
             bukrs              type  bkpf-bukrs,              "n934526
             belnr              type  bkpf-belnr,              "n934526
             gjahr              type  bkpf-gjahr,              "n934526
           end of stype_key,                                   "n934526
                                                               "n934526
           stab_key             type  standard table of        "n934526
                                      stype_key                "n934526
                                      with default key.        "n934526
    Initialwerte setzen
    FORM INIT.
    ENDFORM.
    Selection Screen: Process before output
    FORM PBO.
    ENDFORM.
    Selection Screen: Process after input
    FORM PAI USING FNAME MARK.
      CHECK MARK = SPACE.
    ENDFORM.
    Lesen BKPF und Uebergabe an den Selektionsreport
    FORM PUT_BKPF.
    define locla working areas                                "n934526
    data : l_t_key             type  stab_key,                "n934526
            l_t_key_block       type  stab_key,                "n934526
            l_t_bkpf            type  standard table of bkpf.  "n934526
                                                               "n934526
    ----------------------------------------------------------"n934526
                                                                "n934526
    database seletion improved                                "n934526
    at first read all FI doc keys into a lean table           "n934526
    data: wa like bkpf-belnr.
      SELECT * FROM BKPF
    where budat in br_budat
          AND GJAHR EQ BR_GJAHR-LOW
          AND BLART = 'RV'.
         AND BLART IN BR_BLAR                               "n934526
                                                                "n934526
    check sy-subrc is initial.                                "n934526
                                                               "n934526
    then process the found FI doc keys in small blocks        "n934526
    do.                                                       "n934526
       if  l_t_key[] is initial.                               "n934526
         exit.        " no more keys -> leave this DO loop     "n934526
       endif.                                                  "n934526
                                                               "n934526
      form small blocks with 100 FI docs each                 "n934526
       refresh                  l_t_key_block.                 "n934526
       append lines of l_t_key  from 1 to 100                  "n934526
                                to  l_t_key_block.             "n934526
       delete l_t_key           from 1 to 100.                 "n934526
                                                               "n934526
      read the complete FI doc headers for the block          "n934526
       SELECT *                 FROM BKPF                      "n934526
         into  corresponding fields of table l_t_bkpf          "n934526
           for all entries in l_t_key_block                    "n934526
             WHERE BUKRS = l_t_key_block-BUKRS                 "n934526
               AND BELNR = l_t_key_block-BELNR                 "n934526
               AND GJAHR = l_t_key_block-GJAHR.                "n934526
                                                               "n934526
      provide the complete structure for the PUT              "n934526
       loop at l_t_bkpf         into  bkpf.                    "n934526
        process this company code  : authority and read T001  "n934526
         PERFORM                F1000_COMPANY_CODE.            "n934526
                                                               "n934526
        go on if the first authority check was successful     "n934526
         CHECK : G_S_BUKRS-RETCODE IS INITIAL.                 "n934526
                                                               "n934526
        set the currency key and save the keys                "n934526
         MOVE : G_S_BUKRS-WAERS TO  T001-WAERS,                "n934526
                BKPF-BUKRS      TO  BR_SBUKRS,                 "n934526
               MOVE  BKPF-BELNR       TO  BR_SBELNR.
               MOVE  BKPF-GJAHR      TO  BR_SGJAHR .               "n934526
                BKPF-GJAHR      TO  BR_SGJAHR.                 "n934526
          PUT                    BKPF.                          "n934526
       endloop.                                                "n934526
    enddo.                                                    "n934526
    ENDSELECT.
    ENDFORM.
    Lesen BSEG und Uebergabe an den Selektionsreport
    FORM PUT_BSEG.
    define local working areas                                "n934526
      data : l_t_bseg            type  standard table of bseg.  "n934526
                                                                "n934526
    ----------------------------------------------------------"n934526
    BR_SGSBER = BR_GSBER-LOW.
                                                                "n934526
      SELECT * FROM BSEG                                        "n934526
          WHERE  BELNR EQ BR_SBELNR
          AND GJAHR EQ BR_SGJAHR
          AND GSBER EQ BR_SGSBER.
    check sy-subrc is initial.                                "n934526
                                                                "n934526
    loop at l_t_bseg           into  bseg.                    "n934526
       MOVE BSEG-BUZEI TO BR_SBUZEI.
       MOVE BSEG-EBELN TO BR_SEBELN.
       MOVE BSEG-EBELP TO BR_SEBELP.
       MOVE BSEG-ZEKKN TO BR_SZEKKN.
        PUT BSEG.
      endSELECT.                                                  "n934526
    ENDFORM.
    "n435991
          FORM AUTHORITYCHECK_BKPF                            "n435991
    "n435991
                                                                "n435991
    *FORM AUTHORITYCHECK_BKPF.                                   "n435991
                                                                "n435991
    the authority-check for the company code was successful;  "n435991
    check authority for the document type here                "n435991
                                                                "n435991
    does the buffer contain this document type ?              "n435991
    READ  TABLE  G_T_BLART     INTO  G_S_BLART                "n435991
            WITH  KEY  BLART = BKPF-BLART  BINARY SEARCH.      "n435991
                                                               "n435991
    CASE  SY-SUBRC.                                           "n435991
       WHEN  0.       "document type is known                  "n435991
                                                               "n435991
       WHEN  4.       "docment type is new --> insert          "n435991
         MOVE  SY-TABIX         TO  G_F_TABIX.                 "n435991
         PERFORM                F1200_CREATE_BLART_ENTRY.      "n435991
         INSERT  G_S_BLART      INTO  G_T_BLART                "n435991
                                INDEX  G_F_TABIX.              "n435991
                                                               "n435991
       WHEN  8.       "document type is new --> append         "n435991
         PERFORM                F1200_CREATE_BLART_ENTRY.      "n435991
         APPEND  G_S_BLART      TO  G_T_BLART.                 "n435991
    ENDCASE.                                                  "n435991
                                                               "n435991
    set the return code                                       "n435991
    MOVE  G_S_BLART-RETCODE    TO  SY-SUBRC.                  "n435991
                                                               "n435991
    *ENDFORM.                     "authoritycheck_bkpf           "n435991
                                                               "n435991
    "n435991
          FORM AUTHORITYCHECK_BSEG                            "n435991
    "n435991
                                                                "n435991
    *FORM AUTHORITYCHECK_BSEG.                                   "n435991
                                                               "n435991
    does the buffer contain this document type ?              "n435991
    READ  TABLE  G_T_GSBER     INTO  G_S_GSBER                "n435991
            WITH  KEY  GSBER = BSEG-GSBER  BINARY SEARCH.      "n435991
                                                               "n435991
    CASE  SY-SUBRC.                                           "n435991
       WHEN  0.       "business area is known                  "n435991
                                                               "n435991
       WHEN  4.       "business area is new --> insert         "n435991
         MOVE  SY-TABIX         TO  G_F_TABIX.                 "n435991
         PERFORM                F1300_CREATE_GSBER_ENTRY.      "n435991
         INSERT  G_S_GSBER      INTO  G_T_GSBER                "n435991
                                INDEX  G_F_TABIX.              "n435991
                                                               "n435991
       WHEN  8.       "business area is new --> append         "n435991
         PERFORM                F1300_CREATE_GSBER_ENTRY.      "n435991
         APPEND  G_S_GSBER      TO  G_T_GSBER.                 "n435991
    ENDCASE.                                                  "n435991
                                                               "n435991
    set the return code                                       "n435991
    MOVE  G_S_GSBER-RETCODE    TO  SY-SUBRC.                  "n435991
                                                               "n435991
    *ENDFORM.                     "authoritycheck_bseg           "n435991
                                                               "n435991

    ABAP provides few tools to analyse the perfomance of the objects, which was developed by us.
    Run time analysis transaction SE30
    This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.
    SQL Trace transaction ST05
    by using this tool we can analyse the perfomance issues related to DATABASE calls.
    Perfomance Techniques for improve the perfomance of the object.
    1) ABAP/4 programs can take a very long time to execute, and can make other processes have to wait before executing. Here are some tips to speed up your programs and reduce the load your programs put on the system:
    2) Use the GET RUN TIME command to help evaluate performance. It's hard to know whether that optimization technique REALLY helps unless you test it out.
    3) Using this tool can help you know what is effective, under what kinds of conditions. The GET RUN TIME has problems under multiple CPUs, so you should use it to test small pieces of your program, rather than the whole program.
    4) Generally, try to reduce I/O first, then memory, then CPU activity. I/O operations that read/write to hard disk are always the most expensive operations. Memory, if not controlled, may have to be written to swap space on the hard disk, which therefore increases your I/O read/writes to disk. CPU activity can be reduced by careful program design, and by using commands such as SUM (SQL) and COLLECT (ABAP/4).
    5) Avoid 'SELECT *', especially in tables that have a lot of fields. Use SELECT A B C INTO instead, so that fields are only read if they are used. This can make a very big difference.
    6) Field-groups can be useful for multi-level sorting and displaying. However, they write their data to the system's paging space, rather than to memory (internal tables use memory). For this reason, field-groups are only appropriate for processing large lists (e.g. over 50,000 records). If you have large lists, you should work with the systems administrator to decide the maximum amount of RAM your program should use, and from that, calculate how much space your lists will use. Then you can decide whether to write the data to memory or swap space.
    Use as many table keys as possible in the WHERE part of your select statements.
    7)Whenever possible, design the program to access a relatively constant number of records (for instance, if you only access the transactions for one month, then there probably will be a reasonable range, like 1200-1800, for the number of transactions inputted within that month). Then use a SELECT A B C INTO TABLE ITAB statement.
    8) Get a good idea of how many records you will be accessing. Log into your productive system, and use SE80 -> Dictionary Objects (press Edit), enter the table name you want to see, and press Display. Go To Utilities -> Table Contents to query the table contents and see the number of records. This is extremely useful in optimizing a program's memory allocation.
    9) Try to make the user interface such that the program gradually unfolds more information to the user, rather than giving a huge list of information all at once to the user.
    10) Declare your internal tables using OCCURS NUM_RECS, where NUM_RECS is the number of records you expect to be accessing. If the number of records exceeds NUM_RECS, the data will be kept in swap space (not memory).
    11) Use SELECT A B C INTO TABLE ITAB whenever possible. This will read all of the records into the itab in one operation, rather than repeated operations that result from a SELECT A B C INTO ITAB... ENDSELECT statement. Make sure that ITAB is declared with OCCURS NUM_RECS, where NUM_RECS is the number of records you expect to access.
    12) If the number of records you are reading is constantly growing, you may be able to break it into chunks of relatively constant size. For instance, if you have to read all records from 1991 to present, you can break it into quarters, and read all records one quarter at a time. This will reduce I/O operations. Test extensively with GET RUN TIME when using this method.
    13) Know how to use the 'collect' command. It can be very efficient.
    14) Use the SELECT SINGLE command whenever possible.
    15) Many tables contain totals fields (such as monthly expense totals). Use these avoid wasting resources by calculating a total that has already been calculated and stored.
    Some tips:
    1) Use joins where possible as redundant data is not fetched.
    2) Use select single where ever possible.
    3) Calling methods of a global class is faster than calling function modules.
    4) Use constants instead of literals
    5) Use WHILE instead of a DO-EXIT-ENDDO.
    6) Unnecessary MOVEs should be avoided by using the explicit work area operations
    see the follwing links for a brief insifght into performance tuning,
    http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_Introduction.asp
    1. Debuggerhttp://help.sap.com/saphelp_47x200/helpdata/en/c6/617ca9e68c11d2b2ab080009b43351/content.htm
    2. Run Time Analyser
    http://help.sap.com/saphelp_47x200/helpdata/en/c6/617cafe68c11d2b2ab080009b43351/content.htm
    3. SQL trace
    http://help.sap.com/saphelp_47x200/helpdata/en/d1/801f7c454211d189710000e8322d00/content.htm
    4. CATT - Computer Aided Testing Too
    http://help.sap.com/saphelp_47x200/helpdata/en/b3/410b37233f7c6fe10000009b38f936/frameset.htm
    5. Test Workbench
    http://help.sap.com/saphelp_47x200/helpdata/en/a8/157235d0fa8742e10000009b38f889/frameset.htm
    6. Coverage Analyser
    http://help.sap.com/saphelp_47x200/helpdata/en/c7/af9a79061a11d4b3d4080009b43351/content.htm
    7. Runtime Monitor
    http://help.sap.com/saphelp_47x200/helpdata/en/b5/fa121cc15911d5993d00508b6b8b11/content.htm
    8. Memory Inspector
    http://help.sap.com/saphelp_47x200/helpdata/en/a2/e5fc84cc87964cb2c29f584152d74e/content.htm
    9. ECATT - Extended Computer Aided testing tool.
    http://help.sap.com/saphelp_47x200/helpdata/en/20/e81c3b84e65e7be10000000a11402f/frameset.htm
    Performance tuning for Data Selection Statement
    http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm

  • How to extract the column width in ALv report if its executed in background

    I am executing an ALV report in background , in front end i am getting data properly, in back end for some columns some of the digits are missing.For example if PO no is of 10 digits it will display only 8 becos column size is like that , how to extract coulmns in back ground.
    I have executed in background and checked the spool and  for some of the columns width is not sufficient to display comeplete data so please suggest how to extract the columns sizes if executed inj background for an ALV

    Hi Deepthi,
    you can try with the above mentioned suggestions ,if its worked its fine ,
    If not use Docking container instead of custom container, For ALV in back ground jobs, its suggest to use docking container instead of custom container , below you can find the declaration for docking container and code to use docking and custom container in your program for fore and back ground.
    or you can use docking container alone for both operations.
    Data : G_DOCK1 TYPE REF TO CL_GUI_DOCKING_CONTAINER,
    IF CCON IS INITIAL. (ccon is container name )
    *Check whether the program is run in batch or foreground
        IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.
    *Run in foreground
          CREATE OBJECT CCON
            EXPORTING
              CONTAINER_NAME = 'CON1'.
        CREATE OBJECT GRID1
            EXPORTING
              I_PARENT = parent_1.
    ELSE.
    *Run in background
          CREATE OBJECT GRID1
            EXPORTING
              I_PARENT = G_DOCK1.
        ENDIF.
      ENDIF.
    B&R,
    Saravana.S

Maybe you are looking for

  • Movie with scenes

    How can I make a movie with scenes go back to menu after each scene?

  • Connection not saved - Crystal 11

    Hi, I am designing a report using Crystal 11.  From within the designer I am able to set up a connection to the database and preview the report.  I saved the report and attempted to launch it from a program using the crystal dll to display it.  Howev

  • Open report in maximize mode

    hello, after running the report through form , it does not open in maximize mode. please help me this matter immediately. null

  • Am I supposed to have a remote?

    I have a 27" iMac, which I purchased less than a year ago. Is it supposed to be equipped with a remote? It seems to me that I had one with one of my other Macs, but I never used it.

  • PERL CGI doesnt accept ORACLE+APACHE

    Hi, I am using Oracle+Apache+Perl+DBI/DBD and one thing very strange is happening: Oracle works fine ... Perl + CGI + Apache works fine ... Perl + Oracle works fine ... But when it comes to Access a Perl script (CGI) accessing Oracle in the Netscape