An alternate approach to numerous "if" blocks??

I have a part of code in my application where different objects are instantiated and some processing done based on one variable value. The present approach used numerous "if" statements. I would like to optimize this part of code.
Example of how my code looks now:
if( className.equals("A") {
Class1 c1 = new Class1();
c1.xxx();
c1.zzz();
if(className.equals("B") {
Class2 c2 = new Class2();
c2xxx();
c2zzz();
Will use of reflections in java be a wise choice here?
Is the use of 30 if conditions better or is it better to replace this whole "if" blocks of code with reflection?
Or can any other approach be used here?
Any help will be appreciated!!
Thanks!

interface FactoryByName {
    public abstract boolean likes(final String name);
    public abstract Object create();
class First implements FactoryByName {
    public final boolean likes(final String name) {
        return name.startsWith("A");
    public final Object create() {
        return new First();
class Second implements FactoryByName {
    public final boolean likes(final String name) {
        return name.startsWith("B");
    public final Object create() {
        return new Second();
class Factory {
    private static final FactoryByName[] FACTORIES = {
        new First(), new Second()
    public static final Object createByName(final String name) {
        for (FactoryByName current : FACTORIES) {
            if (current.likes(name)) {
                return current.create();
        return null;
public class Foo {
    public static final void main(final String[] args) {
        Object created = Factory.createByName("A");
        System.out.println(created.getClass().getName());
}- Saish

Similar Messages

  • HP deskjet printing issue - alternate line cut off and blocks

    Hi guys recently bought a deskjet 3050 and it started printing fine, when i had to print out a large document (roughly about 30 pages) it started to cut out sections of text and replacing them with black blocks.
    now when printing it prints the first line fine then the second line is half missing and some words are replaced with black blocks. then the next line is fine, the next is cut off and blocks again and so it continues.
    it only does this with black ink and not colours.
    anyone know a solution?

    It sounds like the black cartridge has failed electrically.  Try printing a diagnostic page as shown in Solution 6 of the page here.  Does this print properly?  I suspect the black nozzle pattern in the upper right will be corrupted.  You might try removing the cartrdige and cleaning the electrical contacts but I suspect the cartridge will need to be replaced.  You can check the cartrdige warranty as shown here assuming it is an original HP cartridge.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Corrupt blocks in the LOB segment 11.2.0.2

    Hello,
    at a dbexport we found corrupted blocks in a LOB-Segment. Then we start rman and do a backup validate check logical database, nothing, rman didn't found any corruption. meanwhile we have repaired the LOB-Segment with restore, now all is ok. But we are confused about this situation, why did rman not found the corruption ? we are making backups with rman (with parameter check logical) and we think rman found logical data corruption. should we now make daily an export to dev_null that we found any corruption.It would be very nice if someone had an answer for us.
    thanks very much

    As far as I know rman validate backup only check for corrupted blocks among database blocks which are used at least once(i.e. used, or free-but at least once used before). For not used blocks RMAN will not report any block corruption.
    The alternate approach could be using dbv utility(Database verification utility)

  • Threads and blocking i/o

    background i am building a multi-cliented server based on the model of one thread per client. client threads wait on a BufferedReader in the run() method for data over the network and take the appropriate action based on the input.
    problem a client thread needs in certains circumstances to kill the thread of another client. since the run() method loops on the blocking input of BufferedReader, any flag or call to interrupt() will not be evaluated until the BufferedReader unblocks. this is bad since it means that the client who is to be killed will not return from run() until the client app talking to the thread sends some data to unblock BufferedReader. the result is a potential dos attack against this server. bad stuff.
    example the current situation: client app one connects to the server spawning Thread-1. client app two connects to the server spawning Thread-2. app two triggers killSomeClient() on Thread-1. Thread-1 continues to linger until client app 1 transmits data to the server, whereupon Thread-1 dies.
    example the required functionality: app one connects to Thread-1. app two connects to Thread-2. app two triggers killSomeClient() on Thread-1. Thread-1 returns from the run() loop and the thread dies immediately.
    what i've tried well, obviously, stop() and destroy() are what i really want... but that's not an option. have tried setting a flag in the while loop to be set by killSomeClient() (ie while(keepRunning && (inputFromClient = in.readLine()) != null) ). have tried interrupt() in the same manner.
    potential solutions i can think of a replacement for stop() or some effective non-blocking read allowing me to loop around the reader, grabbing one char at a time and continuing the loop even if the queue is empty.
    the code example this is a very pared-down version of the code showing only the material necessary for this example (better for readability!). aside from this issue, the application runs.
    someClient
    public class someClient{
        private Socket socket;
        private BufferedReader in;
        private String inputFromClient;
        someClient(Socket socket){
            this.socket = socket;
            this.in = new BufferedReader(new InputStreamReader(theSocket.getInputStream()));
        public void run(){
            try{
                // waits on blocking input
                while((inputFromClient = in.readLine()) != null){
                    System.out.println(inputFromClient);
            }catch(Exception e){}
        public void killSomeClient(someClient killme){
            // help!!
    someServer
    public class someServer{
        private ServerSocket ss;
        public someServer(){
            ss = new ServerSocket(9999);
        public startServer{
            Socket socket = ss.accept();
            someClient client = new someClient(socket);
            client.start();
    }

    problem a client thread needs in certains
    circumstances to kill the thread of another client.
    since the run() method loops on the blocking input of
    BufferedReader, any flag or call to interrupt() will
    not be evaluated until the BufferedReader unblocks.In general, the best approach to terminating a blocking operation is to invalidate the object on which that operation depends. In your case, closing the socket will terminate the read().
    The following is a rather lengthy piece of code that's actually been tested :-)
    import java.io.*;
    import java.net.*;
    public class SocketStopper
        private final static int  PORTNUM = 10000;
        public static void main( String argv[] )
        throws Exception
            System.err.println("Starting server");
            Server server = new Server();
            (new Thread(server)).start();
            Thread.sleep(2000);
            System.err.println("Starting client");
            Client client = new Client();
            (new Thread(client)).start();
            Thread.sleep(2000);
            System.err.println("About to close server socket");
            server.closeSocket();
            Thread.sleep(2000);
            System.err.println("About to exit");
            System.exit(0);
        /** This object establishes a connection to the server port and then
         *  sleeps for 10 minutes without writing anything. This should cause
         *  the reader to block for input.
        public static class Client
        implements Runnable
            public void run()
                try
                    Socket sock = new Socket(InetAddress.getLocalHost(), PORTNUM);
                    System.err.println("Client established connection");
                catch (Exception e)
                    System.err.println("Client unable to establish connection: " + e);
                    return;
                try
                    Thread.sleep(10 * 60000L);
                catch (InterruptedException ignored)
        /** This object sets up a server socket. It accepts the first connection
         *  from that socket and attempts to read from it, which should block.
        public static class Server
        implements Runnable
            private Socket _sock;
            public void run()
                try
                    ServerSocket srv = new ServerSocket(PORTNUM);
                    _sock = srv.accept();
                    System.err.println("Server accepted connection");
                catch (Exception e)
                    System.err.println("Server unable to receive connection: " + e);
                    return;
                try
                    _sock.getInputStream().read();
                    System.err.println("read() completed normally");
                catch (IOException e)
                    System.err.println("read() terminated with exception: " + e);
            public void closeSocket()
                try
                    _sock.close();
                catch (IOException ignored)
    }

  • Alternative approaches for Portlet backing File

    Hi All,
    What would be the best alternate approach if i need to replace all the portlet backing files?
    Thanks in Advance,
    Mohan

    Hello Mohan,
    Can you describe your issue in more detail? Why would you need to replace the backing files, and what would you be replacing them with?
    Kevin

  • Detail block is not populated

    Hi,
    Please suggest me best way to do it. Create a form with two blocks
    1.Master block1 has items client,dc,sku,fromlocation,tolocation which is fetching data
    from RFlog table in RFWH schema
    2.Second block has items client,dc,sku,location which is fetching data from Inv_detail table in MPROD schema.
    These tables are not linked but we can join them using client,dc,sku columns.When click on row in Master
    block then corresponding data from Inv_detail table should display in detail block.
    When there is value in Fromlocation(tolocation will be Null) then detail should show same location and viceversa tolocation.
    problem is there is no way to find in inv_detail which is tolocation or fromlocation.
    sample date
    Master block
    Client        Dc        Sku      fromlocation   tolocation
    10             ABC     Pen         001            
    10             ABC     Pen                            002
    Detail block
    Client      DC     Sku     Location
    10         ABC    Pen       001
    10         ABC    Pen       002My approach: Created master data block based on RFlog then created detail data block based on Inv_detail and unchecked auto-join ,created link with client,dc and sku. in detail block where clause used below query
    :inv_location.location=:rf_blk.fromlocation
    OR :inv_location.location=:rf_blk.tolocationProblem: when ran this form it shows data in all fields of master-data-block and Client,DC,Sku field of detail DB
    there is no data in location field. In detail client,dc and sku item proeprty palatte has COPY_value_item = Mblock.client
    respectively.
    Thanks a lot in advance
    sandy
    Edited by: sandy162 on Jul 20, 2009 3:53 PM

    Let me clarify:
    Your master block rf_blk and detail block inv_location.
    New non-database item location_m added in Master block. This item can be Visible=No and canvas = null (Just don't forget to put formula in this one)
    Do not specify any Where Clause in Master block nor in Detail Block.
    Manually create relation and specify Join Condition like this:
    inv_location.location=rf_blk.location_m
    AND inv_location.client=rf_blk.client
    AND inv_location.dc=rf_blk.dc
    AND inv_location.sku=rf_blk.skuNow you should see that property "Copy value From Item" in inv_location.location is set to rf_blk.location_m, inv_location.client set to copy from rf_blk.client etc.

  • Non-blocking SocketChannel and close - huh?

    It looks like closing a socketchannel that is in non-blocking mode can result in a dead drop of the connection, with some bytes that have already been sent and accepted (as in, 'consumed' from the buffer) being completely dropped.
    In fact, I'm generally confused: Actual C non-blocking code has a similar setup for 'close' as you can see in SocketChannel's OP_CONNECT behaviour - just because you want to connect the socket doesn't mean it magically happends without blocking. Wait for a ready flag, then try again.
    It should work the same way with close (you try to close, but it may not be possible without blocking).
    Is this a huge gaping bug that no one quite figured out just yet, or did I miss something? I loathe to turn on linger, as that's just a crapshoot (you never know if it actually gets through. You could run into funny surprises once the server gets a bit busy. I'd rather not) and tends to cause massive leaks on linux, at least according to some google searches.
    There seems to be slightly better performance (in that I have always received all data sofar) if I close the socket instead of the channel (socketChannel.socket().close() instead of socketChannel.close()) - but this has been a random attempt at 'making it work', and I can't find any documentation that backs up that this will DEFINITELY not lose any information without letting me know somehow. That still sounds impossible with this approach.

    Actual C non-blocking code has a similar setup for
    'close' as you can see in SocketChannel's
    OP_CONNECT behaviour ...No it doesn't. I don't know what you mean by this.
    Closing a socket is asynchronous, but it shouldn't lose any data - if the data can be delivered it will be, followed by the FIN. You don't know when it is delivered, and you don't get to hear about any errors such as an RST coming from the other end, say if it decided to close before reading all the data, or if some intermediate router hung you up.
    I'm wondering if you are really dealing with all the short write and zero length write possibilities, i.e. whether the data isn't really still in your output buffer. Don't wish to teach you to suck eggs but there are some subtleties here.
    Setting a positive linger timeout doesn't really help because Java doesn't tell you if the timeout expired. (I only asked for this about four years ago). You get to wait while any pending data is delivered, but you still have to guess about whether it all went or the timeout expired, and the behaviour after the timeout expires is platform-dependent: some (Windows) issue an RST, others (Unix) keep trying.
    Blocking or non-blocking mode shouldn't make any difference to this (except that Linux will block on a positive linger timeout even in non-blocking mode, which is wrong), and whether you close the channel or the socket is immaterial as one calls the other anyway.
    The reason why OP_CONNECT is different in blocking/non-blocking modes is that in blocking mode it won't return until the SYN-ACK is received, while in non-blocking mode it just sends the SYN and relies on you calling connect() again (at the C level) to collect the SYN-ACK, or not - this is what finishConnect() tells you.
    tends to cause massive leaks on linux, at least
    according to some google searchesIt can't, unless you are referring to the Helix client thing, which appears to be just a badly designed C++ class library with, for some reason, its own linger implementation outside the kernel.

  • Difference between deleting invoice blocking reason and releasing blocked i

    Hi - in mrbr we have two options - one is to delete a blocking reason and the other is to release the invoice.
    It appears that it is possible to delete the blocking reason and this releases the invoice for payment.
    It is also possibel to releease the invoice without deleting the blocking reason and this has the same effect.
    Why do both things appear to do the same?

    Hi,
    The both cases differ in approach, we use delete blocking reason if there is any block existing for the Invoice and after that if the system finds no other block on Invoice header ten the Invoice is automatically released, however if we go for direct release then only those Invoices are released which had blocking reasons but some business transactions have nullified the block already.

  • HT201363 change Alternate Email

    I charge my account with 100SR and when I tried to buy games they say you must enter the answer of security questions but I forget it . I want to change my alternate email because the microsft blocks the email with @9.cn and I can not enter my email. please change my alternate email to [email protected]

    You need to ask Apple to reset your security questions; ways of contacting them include phoning AppleCare and asking for the Account Security team, clicking here and picking a method for your country, and filling out and submitting this form.
    Creating or changing alternate emails won't help, and you can't create or modify a rescue email without correctly answering two of the questions.
    (103968)

  • Spreadsheet question: How to apply formula to entire row?

    I am updating cells which already contain formulas. Can I select the entire row, and apply an additional formula (i.e.: 1.5*) or do I have to do it individually for each cell (there are hundreds)? I need the original formulas to stay in place, and they vary.

    Hi Pamela,
    Welcome to Apple Discussions and the AppleWorks forum.
    (The following was begun before Niel's post, and completed, with a few breaks, some time after it. It addresses a shortcoming with the solution suggested above, so I haven't altered it beyond adding this paragraph.)
    I'm not certain as to exactly what you're requesting here. Do you mean you currently have the same formula in these cells (eg. =(A1-A2) ) and you want to change all of those formulas to (same eg. =1.5*(A1-A2) ). That's cetainly possible if the formulas are in contiguous cells (or in separater groups of contiguoous cells). For the example, select the first cell containing the formula and all the others contiguous to it. Make the change in the entry box, then press command-R to fill the changed formula to selected cells in the same row and to the right, then command-D to fill the formula to all selected cells below the row containing the edited cell.
    OTOH, if you want to make the change to separate (ie. non-contiguous) cells, or to cells which do not contain what's essentially the same formula (with only the cell references changed to reference a cell located in the same relative position), I don't see any way to do it directly within the spreadsheet.
    If the existing formulas are such that you can write a description of where to insert the change, it may be possible to make such a global change through an AppleScript, or through transferring the spreadsheet content to a word processing document, using Find/Change to make the revisions there, then transferr the result back to the spreadsheet (or more cautiously, to a new spreadsheet).
    An AppleScript is someone else's territory. Here's how it could be done using the word processor.
    For the example, I'll assume you want to change ALL formulas in the spreadsheet by adding the instruction to multiply the (result of the) current calculation by 1.5.
    • Open the spreadsheet.
    • Go Options > Display...
    • Check the box "Formulas", Click OK.
    • Select ALL of the cells containing data or a formula.
    • Copy.
    • Open a new word processing document.
    • Paste.
    • Press command-F to open the Find/Change dialogue.
    • Enter "=" in the Find box, press tab, enter "=1.5*" in the Change box (no quotes in either case).
    • Click Change All. OK the two alerts that follow. Close the Find/Change dialogue.
    • Press command-A to Select All. Copy.
    • Open a new spreadsheet document.
    • Paste.
    • Done.
    Limitation: This will work only if the amended formula will give the expected result. Consider the example above, =(A1-A2) with 2 in A1 and 1 in A2.
    As written, the original formula ( =(A1-A2) ) returns a result of "1", and the amended formula ( =1.5*(A1-A2) ) returns the expected result 1.5.
    But it's unlikely the original will have included the parentheses,as they're not necessary to a correct result.
    If the original is =A1-A2, the result is still 1, but the amended formula ( =1.5*A2-A1 ) will return the result "2", not 1.5.
    Revising the beginning of the altered formula to add an opening parenthesis is easy. The difficulty here is telling Find/Change (or AppleScript) how to add the matching closing parenthesis to fomulas but not to the contents of cells containing labels, other text, or nothing at all..
    *An alternate approach:* Rather than revising the existing spreadsheet's formulas, this method transfers the labels and results to a new section of the spreadsheet, multiplies the original results by 1.5, and displays the new result.
    For discussion purposes, I'll assume the current spreadsheet contains 25 columns (A..Y) and 100 rows (1..100) of data and labels.
    • Go Format > Document...
    • Change the default 40 cells wide to 52 (or enough to accomodate twice as many columns as you have containing data now).
    • Click OK
    • Select a cell to the right of the cells containing data in the current spreadsheet. (For the example, choose cell AA1)
    • Enter the following formula:
            =IF(ISTEXT(A1),A1,IF(ISBLANK(A1),"",A1*1.5))
    • Select the block of cells extending right and down from AA1 that matches the size of the original block (for the example, AA1..AY100).
    • Fill the formula Right (command-R) and Down (command-D).
    The formula will copy the text from cells containing text, keep cells blank ("") where the originals were blank, and enter the results, multiplied by 1.5, for cells where the originals contain a formula with a numerical result or a number.
    Limitation: The formula does not distinguish between an entered number and one generated by a formula contained in the referenced cell. All numeric values will be multiplied.
    Regards,
    Barry

  • Check boxes in ALV report

    Can any one please give me any test program for displaying checkboxes in the ALV Report Layout .
    Points will be rewarded even for helpfull answers.
    Thanks ,
    Veerendranath Maddula.

    Hi Veerendranath,
    below is the sample code for that,
    TYPES:
           BEGIN OF TY_VB_AKAP,
             VBELN      TYPE VBELN_VA,                       "Sales Document
             KUNNR      TYPE KUNAG,                          "Sold-to party
             POSNR      TYPE POSNR_VA,                       "Item Number
             MATNR      TYPE MATNR,                          "Material Number
             PMATN      TYPE PMATN,                          "Pricing Reference Material/Newly Created Material
             KWMENG     TYPE KWMENG,                         "Cumulative Order Qty. in Sales Units
             VRKME      TYPE VRKME,                          "Sales Unit
             KZWI1      TYPE KZWI1,                          "Sub Total 1 from pricing procedure for condition
             VKAUS      TYPE ABRVW,                          "Usage Indicator
             WAERK      TYPE WAERK,                          "SD Document Currency
           END   OF TY_VB_AKAP,
           BEGIN OF TY_MARA,
             MATNR      TYPE MATNR,                          "Material Number
             ZZTECHSPEC TYPE ZTECHSPEC,                      "Technical Specification
           END   OF TY_MARA,
           BEGIN OF TY_MVKE,
             MATNR      TYPE MATNR,                          "Material Number
             VKORG      TYPE VKORG,                          "Sales Organization
             VTWEG      TYPE VTWEG,                          "Distribution Channel
             KONDM      TYPE KONDM,                          "Material Pricing Group
    *--Begin of changes for the change request 2007096--26th July 2007--
             VRKME      TYPE VRKME,                          "Sales Unit according to the Material Master
    *--End   of changes for the change request 2007096--26th July 2007--
           END   OF TY_MVKE,
           BEGIN OF TY_VBKD,
             VBELN      TYPE VBELN_VA,                       "Sales Document
             POSNR      TYPE POSNR_VA,                       "Item Number
             BSTKD_E    TYPE BSTKD_E,                        "Used to capture New Material Number
           END   OF TY_VBKD,
           BEGIN OF TY_IHEADER,
             SELECT(1)  TYPE C,                              "Check Box
             VBELN      TYPE VBELN,                          "Sales Document
             KUNNR      TYPE KUNAG,                          "Sold-to Party
           END   OF TY_IHEADER,
           BEGIN OF TY_MESSAGE1,
            VKORG     TYPE VKORG,                            "Sales Organization
            VTWEG     TYPE VTWEG,                            "Distribution Channel
            KUNNR     TYPE KUNAG,                            "Customer number
            KONDM     TYPE KONDM,                            "Material pricing group
            ZCOUNT(2) TYPE N,                                "Zcount
            MSGTYP(1) TYPE C,                                "Message type
            TEXT      TYPE STRING,                           "Message text
           END   OF TY_MESSAGE1,
    *--Begin of changes for the change request 2007106--25th July 2007--
           BEGIN OF TY_MESSAGE1_2,
            VKORG     TYPE VKORG,                            "Sales Organization
            VTWEG     TYPE VTWEG,                            "Distribution Channel
            KUNNR     TYPE KUNAG,                            "Customer number
            KONDM     TYPE KONDM,                            "Material pricin
            MSGTYP(1) TYPE C,                                "Message type
            TEXT      TYPE STRING,                           "Message text
           END   OF TY_MESSAGE1_2,
    *--End   of changes for the change request 2007106--25th July 2007--
           BEGIN OF TY_MESSAGE2,
            VKORG     TYPE VKORG,                            "Sales Organization
            VTWEG     TYPE VTWEG,                            "Distribution Channel
            KUNNR     TYPE KUNAG,                            "Customer number
            MATNR     TYPE MATNR,                            "Material Number
            MSGTYP(1) TYPE C,                                "Message type
            TEXT      TYPE STRING,                           "Message text
           END   OF TY_MESSAGE2,
           BEGIN OF TY_IFINAL,
             VBELN      TYPE VBELN_VA,                       "Sales Document
             KWMENG     TYPE KWMENG,                         "Cumulative Order Qty. in Sales Units
             POSNR      TYPE POSNR_VA,                       "Item Number
             KUNNR      TYPE KUNAG,                          "Sold-to party
             MATNR      TYPE MATNR,                          "Material Number
             VRKME      TYPE VRKME,                          "Sales Unit
             KZWI1      TYPE KZWI1,                          "Sub Total 1 from pricing procedure for condition
             VKAUS      TYPE ABRVW,                          "Usage Indicator
             ZZTECHSPEC TYPE ZTECHSPEC,                      "Technical Specification
             PMATN      TYPE PMATN,                          "Pricing Reference Material/Newly Created Material
             KONDM      TYPE KONDM,                          "Material Pricing Group
    *--Begin of changes for the change request 2007096--26th July 2007--
             WAERK      TYPE WAERK,                          "SD Document Currency
    *--End   of changes for the change request 2007096--26th July 2007--
           END   OF TY_IFINAL,
           BEGIN OF TY_ACC1,
             VBELN      TYPE VBELN_VA,                       "Sales Document
             KUNNR      TYPE KUNAG,                          "Sold-to party
             KONDM      TYPE KONDM,                          "Material Pricing Group
             ZCOUNT(2)  TYPE N,                              "ZCount indicator
             KSTBM      TYPE KSTBM,                          "Quantity
             VRKME      TYPE VRKME,                          "Sales Unit
             ZZTECHSPEC TYPE ZTECHSPEC,                      "Technical Specification
             KZWI1      TYPE KZWI1,                          "Sub Total 1 from pricing procedure for condition
             ERROR(1)   TYPE N,                              "Error Field
    *--Begin of changes for the change request 2007096--26th July 2007--
             WAERK      TYPE WAERK,                          "SD Document Currency
    *--End   of changes for the change request 2007096--26th July 2007--
           END   OF TY_ACC1,
    Important Note : Earlier there were only three accesses and hence this below type was coded as TY_ACC2 depicting
    the type for internal table as a holder of data for second access sequence, but later a new access sequence was
    introduced and was introduced as the second access by itself and hence the sequence which was previously considered
    as second access is going to be third access sequence in reality. The naming standards that are going to be followed
    for the newly introduced access sequence would be XXX_1_2. (For Change request 2007106)
           BEGIN OF TY_ACC2,
             VBELN      TYPE VBELN_VA,                       "Sales Document
             KUNNR      TYPE KUNAG,                          "Sold-to party
             MATNR      TYPE MATNR,                          "Material Number
             KSTBM      TYPE KSTBM,                          "Cumulative Order Qty. in Sales Units
             ZZTECHSPEC TYPE ZTECHSPEC,                      "Technical Specification
             VRKME      TYPE VRKME,                          "Sales Unit
             KZWI1      TYPE KZWI1,                          "Sub Total 1 from pricing procedure for condition
             ERROR(1)   TYPE N,                              "Error field
    *--Begin of changes for the change request 2007096--26th July 2007--
             WAERK      TYPE WAERK,                          "SD Document Currency
    *--End   of changes for the change request 2007096--26th July 2007--
           END   OF TY_ACC2,
    *--Begin of changes for the change request 2007106--24th July 2007--
           BEGIN OF TY_ACC1_2,
             VBELN      TYPE VBELN_VA,                       "Sales Document
             KUNNR      TYPE KUNAG,                          "Sold-to party
             KONDM      TYPE KONDM,                          "Material Pricing Group
             KSTBM      TYPE KSTBM,                          "Quantity
             VRKME      TYPE VRKME,                          "Sales Unit
             ZZTECHSPEC TYPE ZTECHSPEC,                      "Technical Specification
             KZWI1      TYPE KZWI1,                          "Sub Total 1 from pricing procedure for condition
             ERROR(1)   TYPE N,                              "Error field
    *--Begin of changes for the change request 2007096--26th July 2007--
             WAERK      TYPE WAERK,                          "SD Document Currency
    *--End   of changes for the change request 2007096--26th July 2007--
           END   OF TY_ACC1_2,
    *--End   of changes for the change request 2007106--24th July 2007--
    *--Begin of changes for the change request 2007096--26th July 2007--
           BEGIN OF TY_T006,
             MSEHI      TYPE MSEHI,                          "Unit of Measurement
             ZAEHL      TYPE DZAEHL,                         "Numerator for conversion to SI unit
             NENNR      TYPE NENNR,                          "Denominator for conversion into SI unit
           END   OF TY_T006,
    *--End   of changes for the change request 2007096--26th July 2007--
    *--Begin of changes for the change request xxx--2nd Aug 2007--
    *Types of MARM table
           BEGIN OF TY_MARM,
             MATNR TYPE MATNR,                               " Material Number
             MEINH TYPE LRMEI,                               " Alternative Unit of Measure
             UMREZ TYPE UMREZ,                               " Numerator for Conversion to Base UOM
             UMREN TYPE UMREN,                               " Denominator for Conversion to Base UOM
           END   OF TY_MARM.
    *--End   of changes for the change request xxx--2nd Aug 2007--
       D A T A                                                           *
    Internal Table Declarations
    DATA: T_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV,           "Fieldcatalog IT
          T_EVENTS       TYPE SLIS_T_EVENT,                  "Event IT
          T_HEADER       TYPE SLIS_T_LISTHEADER,             "Header IT
          T_VB_AKAP      TYPE STANDARD TABLE OF TY_VB_AKAP,  "To hold records from VBAK & VBAP Table
          T_MARA         TYPE STANDARD TABLE OF TY_MARA,     "To hold records from MARA Table
          T_MVKE         TYPE STANDARD TABLE OF TY_MVKE,     "To hold records from MVKE Table
          T_VBKD         TYPE STANDARD TABLE OF TY_VBKD,     "To hold records from VBKD Table
          T_IHEADER      TYPE STANDARD TABLE OF TY_IHEADER,  "To hold records from VBAK Table
          T_IFINAL       TYPE STANDARD TABLE OF TY_IFINAL,   "To hold cumulative data for ALV
          T_BDCDATA      TYPE STANDARD TABLE OF BDCDATA,     "IT for bdcdata
          T_BDCMSGCOLL   TYPE STANDARD TABLE OF BDCMSGCOLL,  "IT for error messages
          T_MESSAGE1     TYPE STANDARD TABLE OF TY_MESSAGE1, "IT for conditions1 messages
    *--Begin of changes for the change request 2007106--25th July 2007--
          T_MESSAGE1_2   TYPE STANDARD TABLE OF TY_MESSAGE1_2,"ITfor conditions1_2 messages
    *--End   of changes for the change request 2007106--25th July 2007--
          T_MESSAGE2     TYPE STANDARD TABLE OF TY_MESSAGE2, "IT for conditions2 messages
          T_ACC2         TYPE STANDARD TABLE OF TY_ACC2,     "IT for holding data for Second Access Sequence Processing
          T_ACC1         TYPE STANDARD TABLE OF TY_ACC1,     "IT for holding data for First Access Sequence Processing
          T_SELECT       TYPE STANDARD TABLE OF RSPARAMS,    "IT for holding data related to the selection screen
    *--Begin of changes for the change request 2007106--24th July 2007--
          T_ACC1_2       TYPE STANDARD TABLE OF TY_ACC1_2,   "IT for holding data for new intermediate Access Sequence
    *--End   of changes for the change request 2007106--24th July 2007--
    *--Begin of changes for the change request 2007096--26th July 2007--
          T_T006         TYPE STANDARD TABLE OF TY_T006,     "IT for holding T006 Entries
    *--End   of changes for the change request 2007096--26th July 2007--
    *--Begin of changes for the change request xxx--2nd Aug 2007--
          T_MARM         TYPE STANDARD TABLE OF TY_MARM,     "IT for holding entries from MARM
    *--End   of changes for the change request xxx--2nd Aug 2007--
    Work area Declarations
          W_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV,             "Fieldcatalog WA
          W_EVENT        TYPE SLIS_ALV_EVENT,                "Event WA
          W_HEADER       TYPE SLIS_LISTHEADER,               "Header WA
          W_LAYOUT       TYPE SLIS_LAYOUT_ALV,               "Layout WA
          W_KEYINFO      TYPE SLIS_KEYINFO_ALV,              "Key Information WA
          W_VB_AKAP      TYPE TY_VB_AKAP,                    "To hold records from T_VB_AKAP
          W_MARA         TYPE TY_MARA,                       "To hold records from T_MARA
          W_MVKE         TYPE TY_MVKE,                       "To hold records from T_MVKE
          W_VBKD         TYPE TY_VBKD,                       "To hold records from T_VBKD
          W_IHEADER      TYPE TY_IHEADER,                    "To hold records from T_IHEADER
          W_IFINAL       TYPE TY_IFINAL,                     "To hold records from T_IFINAL
          W_PARAMS       TYPE CTU_PARAMS,                    "CTU Params
          W_BDCDATA      TYPE BDCDATA,                       "Work Area for BDCDATA
          W_BDCMSGCOLL   TYPE BDCMSGCOLL,                    "Work Area to collect BDC Messages
          W_MESSAGE1     TYPE TY_MESSAGE1,                   "WA for price conditions1 messages
    *--Begin of changes for the change request 2007106--25th July 2007--
          W_MESSAGE1_2   TYPE TY_MESSAGE1_2,                 "WA for price conditions1_2 messages
    *--End   of changes for the change request 2007106--25th July 2007--
          W_MESSAGE2     TYPE TY_MESSAGE2,                   "WA for price conditions2 messages
          W_ACC2         TYPE TY_ACC2,                       "WA for holding records from T_ACC2
          W_ACC1         TYPE TY_ACC1,                       "WA for holding records from T_ACC1
    *--Begin of changes for the change request 2007106--24th July 2007--
          W_ACC1_2       TYPE TY_ACC1_2,                     "WA for holding records from T_ACC1_2
    *--End   of changes for the change request 2007106--24th July 2007--
    *--Begin of changes for the change request 2007096--26th July 2007--
          W_T006         TYPE TY_T006,                       "WA for holding T_T006 Entries
    *--End   of changes for the change request 2007096--26th July 2007--
    *--Begin of changes for the change request xxx--2nd Aug 2007--
          W_MARM         TYPE TY_MARM,                       "WA for holding entries of T_MARM
    *--End   of changes for the change request xxx--2nd Aug 2007--
    Variable declarations
          G_VKORG       TYPE VKORG,                          "Sales Organization
          G_VTWEG       TYPE VTWEG,                          "Distribution Channel
          G_AUDAT       TYPE AUDAT,                          "Document Date (Date Received/Sent)
          G_VBELN       TYPE VBELN_VA,                       "Sales Document
          G_KUNNR       TYPE KUNAG,                          "Sold-to party
          G_MATNR       TYPE MATNR,                          "Material Number
          G_REPID       TYPE SY-REPID,                       "Program Name
          G_MESSAGE(73) TYPE C,                              "To Capture Message
          G_FLAG1(1)    TYPE C,                              "Flag
          G_ANSWER(1)   TYPE C,                              "Optional Button
    *--Begin of changes for the change request 2007096--26th July 2007--
          G_NUM_SOURCE  TYPE DZAEHL,                         "Holds Numerator value for Source Unit of Measure
          G_NUM_TARGET  TYPE DZAEHL,                         "Holds Numerator value for Target Unit of Measure
          G_DEN_SOURCE  TYPE NENNR,                          "Holds Denominator value for Source Unit of Measure
          G_DEN_TARGET  TYPE NENNR.                          "Holds Denominator value for Target Unit of Measure
    *--End   of changes for the change request 2007096--26th July 2007--
    Constant declarations
    CONSTANTS:
          C_A(1)         TYPE C VALUE 'A',                    "Constant Value A
          C_S(1)         TYPE C VALUE 'S',                    "Constant Value S
          C_U(1)         TYPE C VALUE 'U',                    "Constant Value U
          C_X(1)         TYPE C VALUE 'X',                    "Constant Value X
          C_E(1)         TYPE C VALUE 'E',                    "Constant Value E
          C_I(1)         TYPE C VALUE 'I',                    "Constant Value I
          C_R(1)         TYPE C VALUE 'R',                    "Constant Value R
          C_B(1)         TYPE C VALUE 'B',                    "Document Category is Quotation
          C_HTNAME(10)   TYPE C VALUE 'T_IHEADER',            "Internal table for Header Data
          C_ITNAME(10)   TYPE C VALUE 'T_IFINAL',             "Internal Table with processed data
          C_Q2(2)        TYPE C VALUE 'Q2',                   "Constant Order Reason Q2
          C_100(3)       TYPE C VALUE '100',                  "Popup screen
          C_25(2)        TYPE C VALUE '25',                   "Popup screen
          C_5(1)         TYPE C VALUE '5',                    "Popup screen
          C_1            TYPE I VALUE  1,                     "Value 1 for Error Denotion
          C_2            TYPE I VALUE  2,                     "Value 2 for Error Denotion
          C_3            TYPE I VALUE  3,                     "Value 3 for BDC Error Denotion
          C_1000(4)      TYPE N VALUE 1000,                     "Value 1000
          C_01(2)        TYPE N VALUE '01',                   "Value 01 for Zcount
          C_VK11(4)      TYPE C VALUE 'VK11',                 "Transaction VK11
          C_DYNBEGIN(1)  TYPE C VALUE 'X',                    "Indicator
          C_UPDATE(1)    TYPE C VALUE 'S',                    "Update
          C_DISMODE(1)   TYPE C VALUE 'N',                    "Display
          C_Q3(2)        TYPE C VALUE 'Q3',                   "Quotation Approved
          C_ZBPR(4)      TYPE C VALUE 'ZBPR',                 "Condition Type ZBPR
    *--Begin of changes for the change request xxx--2nd Aug 2007--
          C_ZBPN(4)      TYPE C VALUE 'ZBPN',                 "Condition Type ZBPN
    *--End   of changes for the change request xxx--2nd Aug 2007--
          C_ERROR(5)     TYPE C VALUE 'ERROR'.                "Error screen title
       S E L E C T   O P T I O N S  &  P A R A M E T E R S               *
    Selection-screen Block 1
    SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
    PARAMETERS:     P_VKORG TYPE VKORG OBLIGATORY,           "Sales Organization
                    P_VTWEG TYPE VTWEG OBLIGATORY,           "Distribution Channel
                    P_SPART TYPE SPART DEFAULT '00'.         "Division
    SELECTION-SCREEN END OF BLOCK BLK1.
    SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-002.
    SELECT-OPTIONS: S_AUDAT FOR G_AUDAT,                     "Document Date (Date Received/Sent)
                    S_VBELN FOR G_VBELN,                     "Sales Document
                    S_KUNNR FOR G_KUNNR,                     "Sold-to party
                    S_MATNR FOR G_MATNR.                     "Material Number
    PARAMETERS:     P_VKAUS(2) TYPE N.                       "Usage Indicator
    SELECTION-SCREEN END OF BLOCK BLK2.
      I N I T I A L I Z A T I O N                                        *
    INITIALIZATION.
      CLEAR : G_REPID.                                       "Program Name
      G_REPID = SY-REPID.                                    "Program Name
      A T   S E L E C T I O N   S C R E E N                              *
      CLEAR: G_VKORG,
             G_VTWEG.
    AT SELECTION-SCREEN ON P_VKORG.
      SELECT SINGLE VKORG INTO G_VKORG
                          FROM TVKO
                          WHERE VKORG EQ P_VKORG.
      IF SY-SUBRC NE 0.
        MESSAGE E000(ZS) WITH TEXT-021.
      ENDIF.
    AT SELECTION-SCREEN ON P_VTWEG.
      SELECT SINGLE VTWEG INTO G_VTWEG
                          FROM TVKOV
                          WHERE VKORG EQ P_VKORG
                            AND VTWEG EQ P_VTWEG.
      IF SY-SUBRC NE 0.
        MESSAGE E000(ZS) WITH TEXT-022.
      ENDIF.
      CLEAR: G_VKORG,
             G_VTWEG.
      S T A R T   O F   S E L E C T I O N                                *
    START-OF-SELECTION.
    Data Selection
      PERFORM DATA_RETRIEVAL.
    Build Field Catalog
      PERFORM BUILD_FIELDCATALOG.
    Bulid layout
      PERFORM BUILD_LAYOUT.
    Build Events
      PERFORM BUILD_EVENTS.
    Captures the Values of Selection Screen
      PERFORM CAPTURE_SCREEN.
      E N D   O F   S E L E C T I O N                                    *
    END-OF-SELECTION.
    Display List
      PERFORM DISPLAY_ALV_REPORT.
      F O R M S                                                          *
    *&      Form  DATA_RETRIEVAL
          Retrieves Data for ALV Display
    *--Begin of changes for the change request 2007106--25th July 2007--
    *--End   of changes for the change request 2007106--25th July 2007--
    FORM DATA_RETRIEVAL .
      DATA : L_VKAUS   TYPE VKAUS.            "Variable to hold Usage Indicator
      CLEAR L_VKAUS.
      SELECT VBELN
             KUNNR
        INTO CORRESPONDING FIELDS OF TABLE T_IHEADER
        FROM VBAK
        WHERE VBELN IN S_VBELN
          AND KUNNR IN S_KUNNR
          AND VKORG EQ P_VKORG
          AND AUDAT IN S_AUDAT
          AND VTWEG EQ P_VTWEG
          AND SPART EQ P_SPART
          AND AUGRU EQ C_Q2
          AND VBTYP EQ C_B.
      IF NOT T_IHEADER IS INITIAL.
        IF NOT P_VKAUS IS INITIAL.
    *--Begin of changes for the change request 2007106--25th July 2007--COMMENTED FROM HERE---
         IF P_VKAUS EQ C_1.    "IF Zcount is given as 1 then quotation without zcount should be picked
           "for whom Material Pricing Group should be given.
           SELECT A~VBELN
                  A~KUNNR
                  B~POSNR
                  B~MATNR
                  B~PMATN
                  B~KWMENG
                  B~VRKME
                  B~KZWI1
                  B~VKAUS
            INTO  TABLE T_VB_AKAP
            FROM  VBAK AS A
            JOIN  VBAP AS B
              ON  AVBELN EQ BVBELN
            FOR ALL ENTRIES IN T_IHEADER
            WHERE A~VBELN EQ T_IHEADER-VBELN
              AND B~MATNR IN S_MATNR.
         ELSE.
    *--End   of changes for the change request 2007106--25th July 2007--COMMENTED TILL HERE---
          CONCATENATE 'C' P_VKAUS INTO L_VKAUS.
          SELECT A~VBELN
                 A~KUNNR
                 B~POSNR
                 B~MATNR
                 B~PMATN
                 B~KWMENG
                 B~VRKME
                 B~KZWI1
                 B~VKAUS
    *--Begin of changes for the change request 2007096--26th July 2007--
                 A~WAERK
    *--End   of changes for the change request 2007096--26th July 2007--
           INTO  TABLE T_VB_AKAP
           FROM  VBAK AS A
           JOIN  VBAP AS B
             ON  AVBELN EQ BVBELN
           FOR ALL ENTRIES IN T_IHEADER
            WHERE A~VBELN EQ T_IHEADER-VBELN
              AND B~MATNR IN S_MATNR
              AND B~VKAUS EQ L_VKAUS.
         ENDIF.
        ELSE.
          SELECT A~VBELN
                 A~KUNNR
                 B~POSNR
                 B~MATNR
                 B~PMATN
                 B~KWMENG
                 B~VRKME
                 B~KZWI1
                 B~VKAUS
    *--Begin of changes for the change request 2007096--26th July 2007--
                 A~WAERK
    *--End   of changes for the change request 2007096--26th July 2007--
           INTO  TABLE T_VB_AKAP
           FROM  VBAK AS A
           JOIN  VBAP AS B
             ON  AVBELN EQ BVBELN
           FOR ALL ENTRIES IN T_IHEADER
           WHERE A~VBELN EQ T_IHEADER-VBELN
             AND B~MATNR IN S_MATNR.
        ENDIF.
        IF NOT T_VB_AKAP IS INITIAL.
          SELECT  VBELN
                  POSNR
                  BSTKD_E
             INTO TABLE T_VBKD
             FROM VBKD
             FOR ALL ENTRIES IN T_VB_AKAP
             WHERE VBELN EQ T_VB_AKAP-VBELN
               AND POSNR EQ T_VB_AKAP-POSNR.
        ENDIF.
        SORT T_VBKD BY VBELN POSNR.
        CLEAR W_VB_AKAP.
      After much of coding was completed, Usage of PMATN was dropped and
      the first eighteen characters of the field BSTKD was proposed for usage
      Hence PMATN is overwritten by BSTKD value in the below loop
        LOOP AT T_VB_AKAP INTO W_VB_AKAP.
          CLEAR: W_VBKD,
                 W_VB_AKAP-PMATN.
          READ TABLE T_VBKD INTO W_VBKD
                            WITH KEY VBELN = W_VB_AKAP-VBELN
                                     POSNR = W_VB_AKAP-POSNR
                            BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            W_VB_AKAP-PMATN = W_VBKD-BSTKD_E+0(18).
          ENDIF.
          MODIFY T_VB_AKAP FROM W_VB_AKAP TRANSPORTING PMATN.
          CLEAR W_VB_AKAP.
        ENDLOOP.
        IF NOT T_VB_AKAP IS INITIAL.
        Collecting all Material Numbers along with their Technical Spec data for all the materials available in T_VB_AKAP.
          SELECT    MATNR
                    ZZTECHSPEC
            INTO    TABLE T_MARA
            FROM    MARA
            FOR ALL ENTRIES IN T_VB_AKAP
            WHERE   MATNR EQ T_VB_AKAP-MATNR.
          IF SY-SUBRC EQ 0.
            SORT T_MARA BY MATNR.
          ENDIF.                     "Checking SY-SUBRC for T_MARA
          SELECT    MATNR
                    ZZTECHSPEC
            APPENDING TABLE T_MARA
            FROM    MARA
            FOR ALL ENTRIES IN T_VB_AKAP
            WHERE   MATNR EQ T_VB_AKAP-PMATN.
          IF SY-SUBRC EQ 0.
            SORT T_MARA BY MATNR.
          ENDIF.                     "Checking SY-SUBRC for T_MARA
    *--Begin of changes for the change request xxx--2nd Aug 2007--
        Collecting information into T_MARM for all the available materials so that it could be used for conversion into Alternate UOM
          SELECT MATNR                          " Material Number
                 MEINH                          " Alternate UOM
                 UMREZ                          " Numerator for conversion
                 UMREN                          " Denominator for conversion
            FROM MARM
            INTO TABLE T_MARM
            FOR ALL ENTRIES IN T_VB_AKAP
            WHERE MATNR EQ T_VB_AKAP-MATNR.
          IF SY-SUBRC = 0.
            SORT T_MARM BY MATNR MEINH.
          ENDIF.                     "Checking SY-SUBRC for T_MARM
          SELECT MATNR                          " Material Number
                 MEINH                          " Alternate UOM
                 UMREZ                          " Numerator for conversion
                 UMREN                          " Denominator for conversion
            FROM MARM
            APPENDING TABLE T_MARM
            FOR ALL ENTRIES IN T_VB_AKAP
            WHERE MATNR EQ T_VB_AKAP-PMATN.
          IF SY-SUBRC = 0.
            SORT T_MARM BY MATNR MEINH.
          ENDIF.                     "Checking SY-SUBRC for T_MARM
    *--End   of changes for the change request xxx--2nd Aug 2007--
          SELECT    MATNR
                    VKORG
                    VTWEG
                    KONDM
    *--Begin of changes for the change request 2007096--26th July 2007--
                    VRKME
    *--End   of changes for the change request 2007096--26th July 2007--
            INTO    TABLE T_MVKE
            FROM    MVKE
            FOR ALL ENTRIES IN T_VB_AKAP
            WHERE   MATNR EQ T_VB_AKAP-PMATN.
          IF SY-SUBRC EQ 0.
            SORT T_MVKE BY MATNR VKORG VTWEG.
          ENDIF.                     "Checking SY-SUBRC for T_MVKE
          SELECT    MATNR
                    VKORG
                    VTWEG
                    KONDM
    *--Begin of changes for the change request 2007096--26th July 2007--
                    VRKME
    *--End   of changes for the change request 2007096--26th July 2007--
            APPENDING TABLE T_MVKE
            FROM    MVKE
            FOR ALL ENTRIES IN T_VB_AKAP
            WHERE   MATNR EQ T_VB_AKAP-MATNR.
          IF SY-SUBRC EQ 0.
            SORT T_MVKE BY MATNR VKORG VTWEG.
          ENDIF.                     "Checking SY-SUBRC for T_MVKE
    *--Begin of changes for the change request 2007096--26th July 2007--
          SELECT    MSEHI
                    ZAEHL
                    NENNR
             INTO   TABLE T_T006
             FROM   T006
             FOR ALL ENTRIES IN T_VB_AKAP
             WHERE  MSEHI EQ T_VB_AKAP-VRKME.
          IF SY-SUBRC EQ 0.
            SORT T_T006 BY MSEHI.
          ENDIF.                     "Checking SY-SUBRC for T_T006
          IF NOT T_MVKE IS INITIAL.
            SELECT MSEHI
                   ZAEHL
                   NENNR
            APPENDING TABLE T_T006
            FROM   T006
            FOR ALL ENTRIES IN T_MVKE
            WHERE MSEHI EQ T_MVKE-VRKME.
            IF SY-SUBRC EQ 0.
              SORT T_T006 BY MSEHI.
            ENDIF.                  "Checking SY-SUBRC for T_T006
          ENDIF.                     "Checking for Initial status of internal table T_MVKE
    *--End   of changes for the change request 2007096--26th July 2007--
        ENDIF.                    " FOR T_VB_AKAP NOT INITIAL.
      ENDIF.                    " FOR T_IHEADER NOT INITIAL.
      CLEAR: W_VB_AKAP,
             W_IFINAL.
      LOOP AT T_VB_AKAP INTO W_VB_AKAP.
        W_IFINAL-VBELN  = W_VB_AKAP-VBELN.
        W_IFINAL-KUNNR  = W_VB_AKAP-KUNNR.
        W_IFINAL-POSNR  = W_VB_AKAP-POSNR.
        W_IFINAL-MATNR  = W_VB_AKAP-MATNR.
        W_IFINAL-PMATN  = W_VB_AKAP-PMATN.
        W_IFINAL-KWMENG = W_VB_AKAP-KWMENG.
        W_IFINAL-VRKME  = W_VB_AKAP-VRKME.
        W_IFINAL-KZWI1  = ( W_VB_AKAP-KZWI1 / W_VB_AKAP-KWMENG ) * 1000.
        W_IFINAL-VKAUS  = W_VB_AKAP-VKAUS.
    *--Begin of changes for the change request 2007096--26th July 2007--
        W_IFINAL-WAERK  = W_VB_AKAP-WAERK.
    *--End   of changes for the change request 2007096--26th July 2007--
      Populating Material Pricing Group from New Material Group, if such Group doesn't exist
      Population of Material Pricing Group from Material Number is tried.
      Similar condition does suit for Tech Spec too.
        SORT: T_MVKE BY MATNR VKORG VTWEG,
              T_MARA BY MATNR.
        IF NOT W_VB_AKAP-PMATN IS INITIAL.
          CLEAR W_MVKE.
          READ TABLE    T_MVKE
               INTO     W_MVKE
               WITH KEY MATNR = W_VB_AKAP-PMATN
                        VKORG = P_VKORG
                        VTWEG = P_VTWEG
               BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            W_IFINAL-KONDM = W_MVKE-KONDM.
    *--Begin of changes for the change request 2007096--26th July 2007--
            IF ( W_IFINAL-VRKME NE W_MVKE-VRKME ) AND ( NOT W_MVKE-VRKME IS INITIAL ).
    *--Begin of changes for the change request xxx--2nd Aug 2007--
              CLEAR: W_MARM,
                     G_NUM_SOURCE,
                     G_DEN_SOURCE,
                     G_NUM_TARGET,
                     G_DEN_TARGET.
              READ TABLE T_MARM INTO W_MARM
                                WITH KEY MATNR = W_IFINAL-PMATN
                                MEINH = W_IFINAL-VRKME
                                BINARY SEARCH.
              IF SY-SUBRC EQ 0.
                G_NUM_SOURCE = W_MARM-UMREZ.
                G_DEN_SOURCE = W_MARM-UMREN.
                CLEAR W_MARM.
                READ TABLE T_MARM INTO W_MARM
                                  WITH KEY MATNR = W_IFINAL-PMATN
                                  MEINH = W_MVKE-VRKME
                                  BINARY SEARCH.
                IF SY-SUBRC EQ 0.
                  G_NUM_TARGET = W_MARM-UMREZ.
                  G_DEN_TARGET = W_MARM-UMREN.
                  CLEAR W_MARM.
                  W_IFINAL-KWMENG = W_IFINAL-KWMENG * ( G_NUM_SOURCE / G_DEN_SOURCE ) * ( G_DEN_TARGET / G_NUM_TARGET ).
                  CLEAR W_IFINAL-KZWI1.
                  W_IFINAL-KZWI1   = ( W_VB_AKAP-KZWI1 / W_IFINAL-KWMENG ) * 1000.
                  W_IFINAL-VRKME = W_MVKE-VRKME.
                ENDIF.              "Check SY-SUBRC for W_MARM using W_MVKE-VRKME (Sales UOM)
              ELSE.
    *--End   of changes for the change request xxx--2nd Aug 2007--
                CLEAR: W_T006,
                       G_NUM_SOURCE,
                       G_DEN_SOURCE,
                       G_NUM_TARGET,
                       G_DEN_TARGET.
                READ TABLE T_T006 INTO W_T006 WITH KEY MSEHI = W_IFINAL-VRKME
                                              BINARY SEARCH.
                IF SY-SUBRC EQ 0.
                  G_NUM_SOURCE = W_T006-ZAEHL.          "Numerator to convert specified UOM to SI UOM
                  G_DEN_SOURCE = W_T006-NENNR.          "Denominator to convert specified UOM to SI UOM
                  CLEAR W_T006.
                  READ TABLE T_T006 INTO W_T006 WITH KEY MSEHI = W_MVKE-VRKME
                                                BINARY SEARCH.
                  IF SY-SUBRC EQ 0.
                    G_NUM_TARGET = W_T006-ZAEHL.            "Numerator to convert specified UOM to SI UOM
                    G_DEN_TARGET = W_T006-NENNR.            "Denominator to convert specified UOM to SI UOM
                    CLEAR W_T006.
                    W_IFINAL-KWMENG = W_IFINAL-KWMENG * ( G_NUM_SOURCE / G_DEN_SOURCE ) * ( G_DEN_TARGET / G_NUM_TARGET ).
                    CLEAR W_IFINAL-KZWI1.
                    W_IFINAL-KZWI1   = ( W_VB_AKAP-KZWI1 / W_IFINAL-KWMENG ) * 1000.
                    W_IFINAL-VRKME = W_MVKE-VRKME.
                  ENDIF.          "Check for SY-SUBRC for READ TABLE T_T006 using W_MVKE-VRKME (Sales UOM)
                ENDIF.            "Check for SY-SUBRC for READ TABLE T_T006 using W_IFINAL-VRKME (Quotation UOM)
              ENDIF.              "Check SY-SUBRC for W_MARM using W_IFINAL-VRKME (Quotation UOM)
            ENDIF.              "Check for ( W_IFINAL-VRKME NE W_MVKE-VRKME ) AND ( NOT W_MVKE-VRKME IS INITIAL )
    *--End   of changes for the change request 2007096--26th July 2007--
          ENDIF.
          READ TABLE     T_MARA
               INTO      W_MARA
               WITH KEY  MATNR = W_VB_AKAP-PMATN
               BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            W_IFINAL-ZZTECHSPEC = W_MARA-ZZTECHSPEC.
          ENDIF.    

  • Issues with publishing my iWeb site to .MAC - Progress bar freezes at 100%

    Well, as topic says, i'm having troubles publishing my iWeb site to .MAC now since upgrading to '08. The progress bar reaches full circle, but then nothing. Left it uploading to .Mac for well over 2 hours one time while out of the house...nada. Sometimes i get an error message, sometimes not and have to close iWeb while it's still publishing.
    Any feedback regarding this?
    Thanks in advance.
    /Rich

    Update: After 36 hours, I have successfully managed to upload my entire website via the "Publish All to .Mac" option. I now have blue indicators on the left side of my iWeb program in place of those pesky red ones. How did I do it? Well, I'm not sure. But on my last attempt I looked at the problem from a different perspective, so I took an alternate approach. I had a feeling that I was experiencing a network timeout issue caused by a 3rd party software, so I created a Whitelist entry on my website filtering software that allows unlimited access to "idisk.mac.com";; and "web.mac.com";; domains. I've got two kids at home, so I'm running the free OpenDNS Dashboard service on my network which provides content filtering (blocks adult site, phishing site, etc..). I started using this service two weeks ago. My last website update was a week before that. I figured I had nothing to loose by trying. To my surprise, it worked. Now, it took almost two hours to publish, of which the pie indicator was in the  "filled" position for a nerve racking hour. To reconfirm,  I then made a minor change to one of the pages on my website and re-published. This time using the "Publish to .Mac" option in place of the ALL option and once again it worked. It took less than 5 minutes. Now, I'm not sure if this is a coincidence, maybe Apple fixed the problem, or maybe my website filtering service was causing some type of time out issue all along??  Don't know.. But at least for now, I'm a happy camper since I have my site up.

  • Import photos into Organizer Photoshop 7

    How can I import photos into Organizer from a Desktop folder in the same order that I have arranged and numbered them?

    I can confirm that Barb's method also works in PSE 7.
    Are you on Vista or XP?
    Can you give an example of two files that are in the desired order on Windows Explorer but a different order in PSE?
    Most likely, youre encountering a feature of Vista Windows Explorer. PSE sorts filenames in Folder Location view by the customary dictionary (lexicographic) order used by most applications. For example, the file p15.jpg will come before p2.jpg, because 1 comes before 2 in the dictionary. But Windows Explorer sorts p15.jpg
    after ps2.jpg, because it uses a different rule for sorting filenames if filenames end in numbers, then it sorts files that all have the same leading prefix by the numeric value of that number, not by dictionary order.
    If this is indeed your issue, there are several alternate approaches:
    - Rename the files in Windows Explorer to have names of the form p002.jpg and p015.jpg (that is, the same number of trailing digits).
    - Use PSE albums rather than Windows Explorer to create ordered collections of photos. Its very easy to rearrange the order of photos in albums, much easier than renaming in Windows Explorer. In general, if you want to use the PSE Organizer, then things will go easiest if you do all your file management within PSE and not try to use Windows Explorer.
    - If you want your photos in order of date taken, use the PSEs Display > Thumbnail View to show them in date order. (Folder Location view shows in filename order, and albums show in the order you set.) Use Edit > Adjust Date And Time to change the date taken of any photos as necessary.

  • Using PF_STATUS and USER_COMMAND in ALV

    Hi,
    I have a requirement to place two buttons on the application toolbar of the output ALV list display screen.
    I have to assign functionality for the two buttons.
    How do we do it in ALV?
    Is there any thing in ALV which performs the functionality of  set pf_status and at user_command?

    Hi Sandeep,
    Following code might be useful for you to achieve your goal.
    REPORT  ZSPRENH062.
    TYPE-POOLS : SLIS.                            "Global Type for ALV      
    *    D A T A                                                           *
    * Types declarations
    *ALV Header table type
    TYPES: BEGIN OF TY_HFINAL,
             WERKS TYPE EWERK,                      "Plant
             MATKL TYPE MATKL,                      "Material Group
           END OF TY_HFINAL,
    *ALV Item table type
           BEGIN OF TY_IFINAL,
             WERKS        TYPE EWERK,               "Plant
             MATKL        TYPE MATKL,               "Material Group
             SELECT(1)    TYPE C,                   "Check Box
             MATNR        TYPE MATNR,               "Material No
             LIFNR        TYPE LIFNR,               "Vendor Account No.
             MAKTX        TYPE MAKTX,               "Material Desp.
             BISMT        TYPE BISMT,               "Old material ID
             CPRICE       TYPE KBETR_KOND,          "Contract Price
             FINCONPRI(20) TYPE C,
             INFOREC      TYPE KBETR_KOND,          "Purchase info rec.
             FININFPRI(20) TYPE C,
             MPRICE       TYPE KBETR_KOND,          "Market price
             NREPCOST     TYPE KBETR_KOND,          "Total repl. cost
    *-----           Begin of Changes  EXT-SAP-180  13APR2007            ------*
             PRUOM        TYPE BSTME,               "Purchase Unit of Measure
             TRC_BUOM     TYPE KBETR_KOND,          "Total Repl. Cost in Base UOM
             BSUOM        TYPE MEINS,               "Base Unit of Measure
    *-----           End   of Changes  EXT-SAP-180  13APR2007            ------*
             PREPCOST     TYPE KBETR_KOND,          "Previous repl cost
             VALCHG       TYPE KBETR_KOND,          "Total value change
             PERCHG       TYPE P LENGTH 5 DECIMALS 2,    "Percentage Change
           END OF TY_IFINAL.
    * Internal Table Declarations
    *ALV Header Internal Table
    DATA: T_HFINAL TYPE STANDARD TABLE OF TY_HFINAL INITIAL SIZE 0,
    *ALV Item Internal Table
          T_IFINAL TYPE STANDARD TABLE OF TY_IFINAL INITIAL SIZE 0,
          T_FIELDCATALOG  TYPE SLIS_T_FIELDCAT_ALV,      "Fieldcatalog IT
          T_EVENTS        TYPE SLIS_T_EVENT,             "Event IT
          T_HEADER        TYPE SLIS_T_LISTHEADER,        "Header IT
    * Work area Declarations
    *ALV Header Work Area
          W_HFINAL TYPE TY_HFINAL,
    *ALV Item Work Area
          W_IFINAL TYPE TY_IFINAL,
          W_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV,         "Fieldcatalog WA
          W_EVENT        TYPE SLIS_ALV_EVENT,            "Event WA
          W_HEADER       TYPE SLIS_LISTHEADER,           "Header WA
          W_LAYOUT       TYPE SLIS_LAYOUT_ALV,           "Layout WA
          W_KEYINFO      TYPE SLIS_KEYINFO_ALV,          "Key Information WA
    * Variable declarations
          G_REPID  TYPE SY-REPID,                        "Program Name
          G_ANSWER TYPE C,                               "Optional Button
          G_WERKS TYPE EWERK,
          G_MATKL TYPE MATKL,
          G_MATNR TYPE MATNR,
          G_MTART TYPE MTART,
          G_LIFNR TYPE ELIFN,
          L_CPRICE_C(20) TYPE C,
          L_CPRICE_I(20) TYPE C,
          L_UNITPRICE_C(20) TYPE C,
          L_UNITPRICE_I(20) TYPE C.
    * Constant declarations
    CONSTANTS: C_A(1) TYPE C VALUE 'A',                     "Constant Value A
               C_E(1) TYPE C VALUE 'E',                     "Constant Value E
               C_H(1) TYPE C VALUE 'H',                     "Constant Value H
               C_M(1) TYPE C VALUE 'M',                     "Constant Value M
               C_S(1) TYPE C VALUE 'S',                     "Constant Value S
               C_X(1) TYPE C VALUE 'X',                     "Constant Value X
               C_0(1) TYPE C VALUE '0',                     "Constant Value 0
               C_R(1) TYPE C VALUE 'R',                     "Constant Value R
               C_2(1) TYPE C VALUE '2',                     "Constant Value 2
               C_LANG(2) TYPE C VALUE 'EN',                 "Language English
               C_ZQTE(4) TYPE C VALUE 'ZQTE',               "Condtion type ZQTE
               C_HTNAME(10) TYPE C VALUE 'T_HFINAL',        "Header table name
               C_ITNAME(10) TYPE C VALUE 'T_IFINAL'.        "Item table name
    *    S E L E C T   O P T I O N S  &  P A R A M E T E R S               *
    * Selection-screen Block 1
    SELECTION-SCREEN BEGIN OF BLOCK BLK1
                   WITH FRAME TITLE TEXT-001.         "Begin of Block1
    PARAMETERS : P_EKORG TYPE EKORG OBLIGATORY.       "Pur.Organization
    SELECT-OPTIONS : S_WERKS  FOR G_WERKS OBLIGATORY, "Plant
                     S_MATKL  FOR G_MATKL,            "Material Group
                     S_MATNR  FOR G_MATNR,            "Material No.
                     S_MTART  FOR G_MTART,            "Material Type
                     S_LIFNR  FOR G_LIFNR.            "Vendor
    PARAMETERS : P_PERCHG(3)  TYPE C.                 "Percentage Change
    SELECTION-SCREEN END OF BLOCK BLK1.               "End of Block 1
    * Selection-screen Block 2
    SELECTION-SCREEN BEGIN OF BLOCK BLK2
                   WITH FRAME TITLE TEXT-002.         "Begin of Block2
    PARAMETERS: P_VDATE TYPE DATAM DEFAULT SY-DATUM,  "Valid on date
                P_HDATE TYPE DATAM DEFAULT '29991231'."Horizon date
    SELECTION-SCREEN END OF BLOCK BLK2.               "End of Block 2
    *   I N I T I A L I Z A T I O N                                        *
    INITIALIZATION.
      CLEAR : G_REPID.                                   "Program Name
      G_REPID = SY-REPID.                                "Program Name
    *   A T   S E L E C T I O N   S C R E E N                              *
    AT SELECTION-SCREEN.
    * Validation for Change of Percentage
      IF P_PERCHG LT 0 OR P_PERCHG GT 100.
        MESSAGE E000(ZS) WITH  TEXT-E01.
      ENDIF.
    * Validation for Horizon Date
      IF P_HDATE LE P_VDATE.
        MESSAGE E000(ZS) WITH  TEXT-E02.
      ENDIF.
    *   S T A R T   O F   S E L E C T I O N                                *
    START-OF-SELECTION.
    * Data Selection
      PERFORM DATA_RETRIEVAL.
    * Build Field Catalog
      PERFORM BUILD_FIELDCATALOG.
    * Bulid layout
      PERFORM BUILD_LAYOUT.
    * Build Events
      PERFORM BUILD_EVENTS.
    *   E N D   O F   S E L E C T I O N                                    *
    END-OF-SELECTION.
    * Build Header for Top-Of-Page
      PERFORM BUILD_TOPOFPAGE.
    * Display List
      PERFORM DISPLAY_ALV_REPORT.
    *   F O R M S                                                          *
    *&      Form  data_retrieval
    *   To fetch data from Database table into ALV final Internal table
    FORM DATA_RETRIEVAL.
    * Local Types declarations
    *Types of EORD & EKPO table
      TYPES : BEGIN OF TY_MAIN,
                MATNR TYPE MATNR,               "Material No.
                WERKS TYPE EWERK,               "Plant
                ZEORD TYPE DZEORD,               "No.Source List Rec
                LIFNR TYPE ELIFN,               "Vendor Account No.
                EBELN TYPE EVRTN,               "Agreement Number
                EBELP TYPE EVRTP,               "Agreement Item
                EKORG TYPE EKORG,               "Pur. Organization
                AUTET TYPE AUTET,               "S.L. in Mat.Planning
                MATKL TYPE MATKL,               "Material Group
                MTART TYPE MTART,               "Material Type
                INFNR TYPE INFNR,               "No.Pur.Info Record
    *  Begin of Changes  CON-SAP-99  16/01/2007                            *
                NETPR TYPE BPREI,               "Net Price
    *  End of Changes  CON-SAP-99  16/01/2007                              *
    *-----  Begin of Changes  EXT-SAP-180  13APR2007  ------               *
                MEINS TYPE BSTME,               "Purchase Order Unit of Measure
    *-----  End of Changes    EXT-SAP-180  13APR2007  ------               *
    *           begin 23APR2007  ------
                PEINH TYPE EPEIN,               "Price Unit
    *           end   23APR2007  ------
                PSTYP TYPE PSTYP,               "Item Category
                KONNR TYPE KONNR,               "No.Principal P.A.
                KTPNR TYPE KTPNR,               "Item No.Principal P.A.
              END OF TY_MAIN,
    *Types of MARA table
              BEGIN OF TY_MARA,
                MATNR TYPE MATNR,               "Material No.
                MEINS TYPE MEINS,               "Base Unit of Measure " ext-sap-180  13APR2007
              END OF TY_MARA,
    *Types of MAKT table
              BEGIN OF TY_MAKT,
                MATNR TYPE MATNR,               "Material No.
                MAKTX TYPE MAKTX,               "Material Desp.
              END OF TY_MAKT,
    *Types of MBEW table
              BEGIN OF TY_MBEW,
                MATNR TYPE MATNR,               "Material No.
                BWKEY TYPE BWKEY,               "Valuation Area
    *-----  Begin of Changes  EXT-SAP-180  13APR2007  ------               *
                PEINH TYPE PEINH,                    "Price Unit
    *-----  End of Changes    EXT-SAP-180  13APR2007  ------               *
                ZPLP3 TYPE DZPLP3,               "Future Planned Price
              END OF TY_MBEW,
    *Types of A016_C table
              BEGIN OF TY_A016_C,
                EVRTN  TYPE EBELN,              "Purchasing Doc. No.
                EVRTP  TYPE EBELP,              "Item No.of Pur. Doc.
                KNUMH  TYPE KNUMH,              "Condition rec.no.
              END OF TY_A016_C,
    *Types of A017_P table
              BEGIN OF TY_A017_P,
                LIFNR TYPE ELIFN,               "Vendor Account No.
                MATNR TYPE MATNR,               "Material No.
                EKORG TYPE EKORG,               "Pur. Organization
                WERKS TYPE WERKS_D,               "Plant
                KNUMH TYPE KNUMH,               "Condition rec.no.
              END OF TY_A017_P,
    *Types of A054_M table
              BEGIN OF TY_A054_M,
                KSCHL TYPE KSCHA,               "Condition type
                EKORG TYPE EKORG,               "Pur. Organization
                MATKL TYPE MATKL,               "Material Group
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
                MATNR TYPE MATNR,               "Material Number
                DATBI TYPE KODATBI,              " Validity end date of the condition record  04APR07
                DATAB TYPE KODATAB,              " Validity start date of the condition record 04APR0
    *    End of Changes        EXT-SAP-180    02APR2007          *
                KNUMH TYPE KNUMH,               "Condition rec.no.
              END OF TY_A054_M,
    *Types of KONP_P table
              BEGIN OF TY_KONP_P,
                KNUMH TYPE KNUMH,               "Condition rec.no.
                KBETR TYPE KBETR_KOND,          "Rate
                KONWA TYPE KONWA,               "Rate unit
                KPEIN TYPE KPEIN,               "Condition pricing unit
                KMEIN TYPE KMEIN,               "Condition Unit
              END OF TY_KONP_P,
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
    * Types of A049 table
              BEGIN OF TY_A049,
                KSCHL TYPE KSCHA,              " Condition Type
                EKORG TYPE EKORG,              " Purchasing Organization
                MATKL TYPE MATKL,              " Material Group
                MATNR TYPE MATNR,              " Material Number
                DATBI TYPE KODATBI,              " Validity end date of the condition record  04APR07
                DATAB TYPE KODATAB,              " Validity start date of the condition record 04APR07
                KNUMH TYPE KNUMH,              " Condition Record Number
              END OF TY_A049,
    * Types of KONP_C table
              BEGIN OF TY_KONP_C,
                KNUMH TYPE KNUMH,               "Condition rec.no.
                KOPOS TYPE KOPOS,
                KSCHL TYPE KSCHA,               "Condition type
                KBETR TYPE KBETR_KOND,               "Rate
                KONWA TYPE KONWA,               "Rate unit
              END OF TY_KONP_C,
    *Types of KONM_C table
             BEGIN OF TY_KONM_C,
                KNUMH TYPE KNUMH,               "Condition rec.no.
                KOPOS TYPE KOPOS,               "Seq. no. of the condition
                KSTBM TYPE KSTBM,               "Condition scale quan.
                KBETR TYPE KBETR,               "Rate
              END OF TY_KONM_C,
    *Types of KONM_P table
              BEGIN OF TY_KONM_P,
                KNUMH TYPE KNUMH,               "Condition rec.no.
                KSTBM TYPE KSTBM,               "Condition scale quan.
                KBETR TYPE KBETR,               "Rate
              END OF TY_KONM_P,
    *    End of Changes        EXT-SAP-180    02APR2007          *
    *-----  Begin of Changes  EXT-SAP-180  13APR2007  ------*
    *Types of EINE table
               BEGIN OF TY_EINE,
                 INFNR TYPE INFNR,                     " Number of Purchase Info Record
                 EKORG TYPE EKORG,                     " Purchasing Organization
                 WERKS TYPE EWERK,                     " Plant
                 PEINH TYPE EPEIN,                     " Price Unit
                 BPRME TYPE BBPRM,                     " Order Price Unit (Purchasing)
               END   OF TY_EINE,
    *Types of MARM table
             BEGIN OF TY_MARM,
                 MATNR TYPE MATNR,                     " Material Number
                 MEINH TYPE LRMEI,                     " Alternative Unit of Measure
                 UMREZ TYPE UMREZ,                     " Numerator for Conversion to Base UOM
                 UMREN TYPE UMREN,                     " Denominator for Conversion to Base UOM
              END   OF TY_MARM,
    *-----  End   of Changes  EXT-SAP-180  13APR2007  ------*
    *Types of EKAB table
              BEGIN OF TY_EKAB,
                KONNR TYPE KONNR,               "No of Principal P.A
                KTPNR TYPE KTPNR,               "Item of Principal P.A
                EBELN TYPE EBELN,               "Purchasing Doc. No.
                MENGE TYPE BSTMG,               "P.O. Quantity
              END OF TY_EKAB,
    *Types of EKPO table
             BEGIN OF TY_EKPO,
                INFNR TYPE INFNR,               "No of Pur.Info Rec.
                EBELN TYPE EBELN,               "Purchasing Doc. No.
                MENGE TYPE MENGE_D,             "P.O. Quantity
              END OF TY_EKPO.
    * Local Internal table declarations
      DATA: T_MAIN    TYPE STANDARD TABLE OF TY_MAIN,
            T_MAIN1   TYPE STANDARD TABLE OF TY_MAIN,
            T_MARA    TYPE STANDARD TABLE OF TY_MARA,
            T_MBEW    TYPE STANDARD TABLE OF TY_MBEW,
            T_MAKT    TYPE STANDARD TABLE OF TY_MAKT,
            T_A016_C  TYPE STANDARD TABLE OF TY_A016_C,
            T_A017_P  TYPE STANDARD TABLE OF TY_A017_P,
            T_A054_M  TYPE STANDARD TABLE OF TY_A054_M,
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
            T_KONP_C  TYPE STANDARD TABLE OF TY_KONP_C,
            T_A049    TYPE STANDARD TABLE OF TY_A049,
    *    End of Changes        EXT-SAP-180    02APR2007          *
    *-----           Begin of Changes  EXT-SAP-180  13APR2007            ------*
            T_EINE    TYPE STANDARD TABLE OF TY_EINE,
            T_MARM    TYPE STANDARD TABLE OF TY_MARM,
    *-----           End   of Changes  EXT-SAP-180  13APR2007            ------*
            T_KONP_P  TYPE STANDARD TABLE OF TY_KONP_P,
            T_KONP_M  TYPE STANDARD TABLE OF TY_KONP_P,
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
            T_KONM_C  TYPE STANDARD TABLE OF TY_KONM_C,
            T_KONM_P  TYPE STANDARD TABLE OF TY_KONM_P,
    *    End of Changes        EXT-SAP-180    02APR2007          *
            T_EKAB    TYPE STANDARD TABLE OF TY_EKAB,
            T_EKPO    TYPE STANDARD TABLE OF TY_EKPO,
    * Local Work Area declarations
             W_MAIN    TYPE TY_MAIN,
             W_MARA    TYPE TY_MARA,
             W_MBEW    TYPE TY_MBEW,
             W_A016_C  TYPE TY_A016_C,
             W_A017_P  TYPE TY_A017_P,
             W_A054_M  TYPE TY_A054_M,
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
             W_KONP_C  TYPE TY_KONP_C,
             W_MAIN1_T TYPE TY_MAIN,
             W_A049_T  TYPE TY_A049,
    *    End of Changes        EXT-SAP-180    02APR2007          *
    *-----           Begin of Changes  EXT-SAP-180  13APR2007            ------*
             W_EINE    TYPE TY_EINE,
             W_MARM    TYPE TY_MARM,
    *-----           End   of Changes  EXT-SAP-180  13APR2007            ------*
             W_KONP_P  TYPE TY_KONP_P,
             W_KONP_M  TYPE TY_KONP_P,
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
             W_KONM_C  TYPE TY_KONM_C,
             W_KONM_P  TYPE TY_KONM_P,
             W_KONM1   TYPE TY_KONM_C,
             W_KONM2   TYPE TY_KONM_P,
    *    End of Changes        EXT-SAP-180    02APR2007          *
             W_EKAB    TYPE TY_EKAB,
             W_EKPO    TYPE TY_EKPO,
             W_MAKT    TYPE TY_MAKT,
    * Local Variable declarations
             L_PERPRICE TYPE KBETR_KOND,             "Local Percentage price
             L_PERUNIT  TYPE KPEIN,             "Condition Pricing Unit
             L_MARPRICE TYPE KBETR_KOND,             "Local Market price
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
             L_KBETR    TYPE KBETR,
             L_INDEX    TYPE SY-TABIX,               "Tab Index
    *    End of Changes        EXT-SAP-180    02APR2007          *
    *  Begin of Changes  CON-SAP-99  11/12/2006                            *
             L_STR TYPE STRING.
    *  End of Changes  CON-SAP-99  11/12/2006                              *
    * GET SOURCE LIST
      SELECT  A~MATNR                                "Material No.
              A~WERKS                                "Plant
              A~ZEORD                                "No.Source List Rec
              A~LIFNR                                "Vendor Account No.
              A~EBELN                                "Agreement Number
              A~EBELP                                "Agreement Item
              A~EKORG                                "Pur. Organization
              A~AUTET                                "S.L. in Mat.Planning
              B~MATKL                                "Material Group
              B~MTART                                "Material Type
              B~INFNR                                "No.Pur.Info Record
    *  Begin of Changes  CON-SAP-99  16/01/2007                            *
              B~NETPR                                "Net price
    *  End of Changes  CON-SAP-99  16/01/2007                              *
    *-----  Begin of Changes  EXT-SAP-180  13APR2007  ------               *
              B~MEINS                                "Purchase Order Unit of Measure
    *-----  End of Changes    EXT-SAP-180  13APR2007  ------               *
    *           begin 23APR2007  ------
              B~PEINH                                "Price Unit
    *           end   23APR2007  ------
              B~PSTYP                                "Pur. Doc. Category
              B~KONNR                                "No.Principal P.A.
              B~KTPNR                                "Item No.Principal P.A.
                 INTO TABLE T_MAIN
                 FROM  EORD AS A INNER JOIN EKPO AS B
                 ON  ( A~EBELN EQ B~EBELN
                 AND   A~EBELP EQ B~EBELP )
                 WHERE A~MATNR IN S_MATNR
                 AND   A~LIFNR IN S_LIFNR
                 AND   A~WERKS IN S_WERKS
                 AND   B~MATKL IN S_MATKL
                 AND   B~MTART IN S_MTART
                 AND   A~EKORG EQ P_EKORG
                 AND   A~VDATU LE P_VDATE
                 AND   A~BDATU GE P_VDATE
                 AND ( A~AUTET EQ 1
                 OR    A~AUTET EQ 2 ).
      IF SY-SUBRC = 0.
        SORT T_MAIN BY MATNR WERKS.
        DELETE ADJACENT DUPLICATES FROM T_MAIN
                              COMPARING MATNR
                                        WERKS.
        T_MAIN1[] = T_MAIN[].
        DELETE ADJACENT DUPLICATES FROM T_MAIN1
                              COMPARING MATNR.
    * GET MATERIAL DESCRIPTION
        SELECT MATNR                                 "Material No
               MAKTX                                 "Material Desp.
                 FROM MAKT
                 INTO TABLE T_MAKT
                 FOR ALL ENTRIES IN T_MAIN1
                 WHERE MATNR EQ T_MAIN1-MATNR
                 AND   SPRAS EQ C_LANG.
        IF SY-SUBRC = 0.
          SORT T_MAKT BY MATNR.
        ENDIF.
    *-----  Begin of Changes  EXT-SAP-180  13APR2007  ------               *
    * GET PURCHASE ORDER UNIT OF MEASURE FOR INFO RECORDS FROM EINE
        SELECT INFNR                            " Number of Purchase Info Record
               EKORG                            " Purchasing Organization
               WERKS                            " Plant
               PEINH                            " Price Unit
               BPRME                            " Order Price Unit
                 FROM EINE
                 INTO TABLE T_EINE
                 FOR ALL ENTRIES IN T_MAIN1
                 WHERE INFNR EQ T_MAIN1-INFNR
                   AND EKORG EQ T_MAIN1-EKORG
                   AND ( ESOKZ EQ C_0 OR ESOKZ EQ C_2 )            "Purchasing Info Record Category = Standard
                   AND WERKS EQ T_MAIN1-WERKS.
        IF SY-SUBRC = 0.
          SORT T_EINE BY INFNR EKORG WERKS.
        ENDIF.
        SELECT MATNR                          " Material Number
               MEINH                          " Alternate UOM
               UMREZ                          " Numerator for conversion
               UMREN                          " Denominator for conversion
                 FROM MARM
                 INTO TABLE T_MARM
                 FOR ALL ENTRIES IN T_MAIN1
                 WHERE MATNR EQ T_MAIN1-MATNR.
        IF SY-SUBRC = 0.
          SORT T_MARM BY MATNR MEINH.
        ENDIF.
    *-----  End of Changes    EXT-SAP-180  13APR2007  ------               *
    * GET BASE UNIT OF MEASURE
        SELECT MATNR                                 "Material No.
               MEINS                                 "Base unit of measure " ext-sap-180 13APR2007
                 INTO  TABLE T_MARA
                 FROM  MARA
                 FOR ALL ENTRIES IN T_MAIN1
                 WHERE MATNR EQ T_MAIN1-MATNR.
        IF SY-SUBRC = 0.
          SORT T_MARA BY MATNR.
        ENDIF.
    * GET CONTRACT PRICE
        REFRESH T_MAIN1[].
        T_MAIN1[] = T_MAIN[].
        SORT T_MAIN1 BY PSTYP.
        DELETE T_MAIN1 WHERE PSTYP = 2.
        IF T_MAIN1 IS NOT INITIAL.
          SORT T_MAIN1 BY EBELN EBELP.
    * Get Condition Record Number based on Purchasing Document Number
          SELECT EVRTN                               "Purchasing Doc. No.
                 EVRTP                               "Item No.of Pur. Doc.
                 KNUMH                               "Condition rec.no.
                   FROM A016
                   INTO TABLE T_A016_C
                   FOR ALL ENTRIES IN  T_MAIN1
                   WHERE KAPPL EQ C_M
                   AND   EVRTN EQ T_MAIN1-EBELN
                   AND   EVRTP EQ T_MAIN1-EBELP
                   AND   DATBI GE P_VDATE
                   AND   DATAB LE P_VDATE.
          IF SY-SUBRC = 0.
            SORT T_A016_C BY EVRTN EVRTP.
          ENDIF.
          SORT T_MAIN1 BY KONNR KTPNR.
    *Get Condition Record No. based on Principal Purchasing Document No
          SELECT EVRTN                               "Purchasing Doc. No.
                 EVRTP                               "Item No.of Pur. Doc.
                 KNUMH                               "Condition rec.no.
                   FROM A016
                   APPENDING TABLE T_A016_C
                   FOR ALL ENTRIES IN  T_MAIN1
                   WHERE KAPPL EQ C_M
                   AND   EVRTN EQ T_MAIN1-KONNR
                   AND   EVRTP EQ T_MAIN1-KTPNR
                   AND   DATBI GE P_VDATE
                   AND   DATAB LE P_VDATE.
          IF T_A016_C IS NOT INITIAL.
            SORT T_A016_C BY EVRTN EVRTP.
    *Get Rate & unit for all the Condition Record No.(Contract Price)
            SELECT KNUMH                             "Condition rec.no.
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
                   KOPOS                             "Seq. No. of the condition
                   KSCHL                             "Condition Type
    *    End of Changes        EXT-SAP-180    02APR2007          *
                   KBETR                             "Rate
                   KONWA                             "Rate unit
                     FROM KONP
                     INTO TABLE T_KONP_C
                     FOR ALL ENTRIES IN T_A016_C
                     WHERE KNUMH EQ T_A016_C-KNUMH
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
                     AND LOEVM_KO EQ SPACE.
    *    End of Changes        EXT-SAP-180    02APR2007          *
            IF SY-SUBRC = 0.
              SORT T_KONP_C BY KNUMH.
            ENDIF.
    * Get Condition scale quantity & Rate for all the Condition Record No.
            SELECT KNUMH                             "Condition rec.no.
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
                   KOPOS                             "Seq. No. of the condition
    *    End of Changes        EXT-SAP-180    02APR2007          *
                   KSTBM                             "Condition scale quan.
                   KBETR                             "Rate
                     FROM KONM
                     INTO TABLE T_KONM_C
                     FOR ALL ENTRIES IN T_A016_C
                     WHERE KNUMH EQ T_A016_C-KNUMH.
            IF SY-SUBRC = 0.
              SORT T_KONM_C BY KNUMH
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
                               KOPOS
    *    End of Changes        EXT-SAP-180    02APR2007          *
                               KSTBM
                               DESCENDING.
            ENDIF.
    * Get PO Doc. No. & Quantity based on Principal Purchasing Doc. No
            SELECT KONNR                             "No of Principal P.A
                   KTPNR                             "Item of Principal P.A
                   EBELN                             "Purchasing Doc. No.
                   MENGE                             "P.O. Quantity
                     FROM EKAB
                     INTO TABLE T_EKAB
                     FOR ALL ENTRIES IN T_A016_C
                     WHERE KONNR EQ T_A016_C-EVRTN
                     AND   KTPNR EQ T_A016_C-EVRTP.
            IF SY-SUBRC = 0.
              SORT T_EKAB BY KONNR KTPNR EBELN DESCENDING.
            ENDIF.
          ENDIF.
        ENDIF.
    * GET PURCHASING INFO RECORDS PRICE
        REFRESH T_MAIN1[].
        T_MAIN1[] = T_MAIN[].
        DELETE T_MAIN1 WHERE PSTYP <> 2.
        IF T_MAIN1 IS NOT INITIAL.
          SORT T_MAIN1 BY LIFNR MATNR EKORG WERKS.
    * Get Condition Record No based on Vendor,Material,Pur.org & Plant
          SELECT LIFNR                               "Vendor Account No.
                 MATNR                               "Material No.
                 EKORG                               "Pur. Organization
                 WERKS                               "Plant
                 KNUMH                               "Condition rec.no.
                   FROM A017
                   INTO TABLE T_A017_P
                   FOR ALL ENTRIES IN  T_MAIN1
                   WHERE LIFNR EQ T_MAIN1-LIFNR
                   AND   MATNR EQ T_MAIN1-MATNR
                   AND   EKORG EQ T_MAIN1-EKORG
                   AND   WERKS EQ T_MAIN1-WERKS
                   AND   DATBI GE P_VDATE
                   AND   DATAB LE P_VDATE.
          IF SY-SUBRC = 0.
            SORT T_A017_P BY LIFNR MATNR EKORG WERKS.
    *Get Rate & unit for all the Condition Rec.No.(Pur. info Rec Price)
            SELECT KNUMH                             "Condition rec.no.
                   KBETR                             "Rate
                   KONWA                             "Rate unit
                   KPEIN                             "Condition pricing unit
                   KMEIN                             "Condition Unit
                     FROM KONP
                     INTO TABLE T_KONP_P
                     FOR ALL ENTRIES IN T_A017_P
                     WHERE KNUMH EQ T_A017_P-KNUMH.
            IF SY-SUBRC = 0.
              SORT T_KONP_P BY KNUMH.
            ENDIF.
    * Get Condition scale quantity & Rate for all the Condition Record No.
            SELECT KNUMH                             "Condition rec.no.
                   KSTBM                             "Condition scale quan.
                   KBETR                             "Rate
                     FROM KONM
                     INTO TABLE T_KONM_P
                     FOR ALL ENTRIES IN T_A017_P
                     WHERE KNUMH EQ T_A017_P-KNUMH.
            IF SY-SUBRC = 0.
              SORT T_KONM_P BY KNUMH KSTBM DESCENDING.
            ENDIF.
          ENDIF.
    * Get PO Doc. No. & Quantity based on Principal Purchasing Doc. No
          SORT T_MAIN1 BY INFNR.
          SELECT INFNR                             "No of Pur.Info Rec.
                 EBELN                             "Purchasing Doc. No.
                 MENGE                             "P.O. Quantity
                   FROM EKPO
                   INTO TABLE T_EKPO
                   FOR ALL ENTRIES IN T_MAIN1
                   WHERE INFNR EQ T_MAIN1-INFNR
                   AND   WERKS EQ T_MAIN1-WERKS
                   AND   BSTYP EQ 'F'.
          IF SY-SUBRC = 0.
            SORT T_EKPO BY INFNR EBELN DESCENDING.
          ENDIF.
        ENDIF.
    * GET MARKET PRICE
        REFRESH T_MAIN1[].
        T_MAIN1[] = T_MAIN[].
        DELETE ADJACENT DUPLICATES FROM T_MAIN1 COMPARING EKORG MATKL.
        P_VDATE = P_VDATE + 1.
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
    * Get Condition Record No based on Material Number
        SELECT KSCHL
               EKORG
               MATNR
               DATBI    "EXT-SAP-180 04Apr07
               DATAB    "EXT-SAP-180 04Apr07
               KNUMH
         FROM  A049
         INTO CORRESPONDING FIELDS OF TABLE T_A049
         FOR ALL ENTRIES IN T_MAIN
         WHERE KSCHL EQ C_ZQTE
           AND EKORG EQ T_MAIN-EKORG
           AND MATNR EQ T_MAIN-MATNR
           AND ESOKZ EQ C_0.
        IF SY-SUBRC EQ 0.                               " if entries exists in t_a049
          SORT T_A049 BY EKORG MATNR
                         DATBI DATAB.                   " EXT-SAP-180 04Apr07
          CLEAR L_INDEX.
          LOOP AT T_A049 INTO W_A049_T.
            L_INDEX = SY-TABIX.
            READ TABLE T_MAIN INTO W_MAIN1_T
                       WITH KEY EKORG = W_A049_T-EKORG
                                MATNR = W_A049_T-MATNR
                       BINARY SEARCH.
            IF SY-SUBRC EQ 0.
              W_A049_T-MATKL = W_MAIN1_T-MATKL.
              MODIFY T_A049 FROM W_A049_T
                            INDEX L_INDEX
                            TRANSPORTING MATKL.
            ENDIF.
            CLEAR: W_A049_T,
                   W_MAIN1_T,
                   L_INDEX.
          ENDLOOP.
    * Get Rate & unit for all the Condition Record No. (Market price)
          SELECT KNUMH                               "Condition rec.no.
                 KBETR                               "Rate
                 KONWA                               "Rate unit
                 KPEIN                               "Condition Pricing Unit
                 KMEIN                               "Condition Unit
                 FROM KONP
                 INTO TABLE T_KONP_M
                 FOR ALL ENTRIES IN T_A049
                 WHERE KNUMH EQ T_A049-KNUMH.
          IF SY-SUBRC = 0.
            SORT T_KONP_C BY KNUMH.
          ENDIF.
        ENDIF.
    *    End of Changes        EXT-SAP-180    02APR2007           *
    *Get Condition Record No based on Condition type, Pur.Org.,Mat. group
        SELECT KSCHL                                 "Condition type
               EKORG                                 "Pur. Organization
               MATKL                                 "Material Group
               DATBI                                 "Valid to date   EXT-SAP-180 04Apr07
               DATAB                                 "Valid from date EXT-SAP-180 04Apr07
               KNUMH                                 "Condition rec.no.
                 FROM A054
                 INTO CORRESPONDING FIELDS OF TABLE T_A054_M
                 FOR ALL ENTRIES IN  T_MAIN
                 WHERE KSCHL EQ  C_ZQTE
                 AND   EKORG EQ  T_MAIN-EKORG
                 AND   MATKL EQ  T_MAIN-MATKL
                 AND   ESOKZ EQ C_0.
        IF SY-SUBRC = 0.
          SORT T_A054_M BY EKORG MATKL
                           DATBI DATAB. " added by SAP-EXT-180 04Apr07
    * Get Rate & unit for all the Condition Record No. (Market price)
          SELECT KNUMH                               "Condition rec.no.
                 KBETR                               "Rate
                 KONWA                               "Rate unit
                 KPEIN                               "Condition Pricing Unit
                 KMEIN                               "Condition Unit
                 FROM KONP
                 APPENDING TABLE T_KONP_M
                 FOR ALL ENTRIES IN T_A054_M
                 WHERE KNUMH EQ T_A054_M-KNUMH.
          IF SY-SUBRC = 0.
            SORT T_KONP_C BY KNUMH KOPOS KSCHL.
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
            SORT T_KONP_M BY KNUMH.
    *    End of Changes        EXT-SAP-180    02APR2007          *
          ENDIF.
        ENDIF.
    * GET PREVIOUS REPLACEMENT COST
        SELECT MATNR                                 "Material No.
               BWKEY                                 "Valuation Area
    *-----  Begin of Changes  EXT-SAP-180  13APR2007  ------               *
               PEINH                                 "Price Unit
    *-----  End of Changes    EXT-SAP-180  13APR2007  ------               *
               ZPLP3                                 "Future Planned Price
                 FROM MBEW
                 INTO TABLE T_MBEW
                 FOR ALL ENTRIES IN  T_MAIN
                 WHERE MATNR EQ T_MAIN-MATNR
                 AND   BWKEY EQ T_MAIN-WERKS.
        IF SY-SUBRC = 0.
          SORT  T_MBEW BY MATNR BWKEY.
        ENDIF.
    * TRANSFERING DATA INTO FINAL INTERNAL TABLE
        CLEAR : W_MAIN.
        LOOP AT T_MAIN INTO W_MAIN.
    * Clear the Work area
          CLEAR : W_MAKT,
                  W_MARA,
                  W_MBEW,
                  W_A016_C,
                  W_A017_P,
                  W_A054_M,
                  W_KONP_C,
                  W_KONP_P,
                  W_KONP_M,
                  W_KONM_C,
                  W_KONM_P,
                  W_KONM1,
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
                  W_KONM2,
                  W_A049_T,
    *    End of Changes        EXT-SAP-180    02APR2007          *
                  W_EKAB,
                  W_EKPO.
          CLEAR : W_HFINAL,
                  W_IFINAL.
    * PLANT, MATERIAL GROUP
          W_HFINAL-WERKS = W_MAIN-WERKS.             "Plant(H)
          W_HFINAL-MATKL = W_MAIN-MATKL.             "Material Group(H)
          W_IFINAL-WERKS = W_MAIN-WERKS.             "Plant(I)
          W_IFINAL-MATKL = W_MAIN-MATKL.             "Material Group(I)
    * MATERIAL NUMBER, VENDER NUMBER
          W_IFINAL-MATNR = W_MAIN-MATNR.             "Material No.
          W_IFINAL-LIFNR = W_MAIN-LIFNR.             "Vendor
    * MATERIAL DESCRIPTION
          READ TABLE T_MAKT INTO W_MAKT
                            WITH KEY MATNR = W_MAIN-MATNR
                            BINARY SEARCH.
          IF SY-SUBRC = 0.
            W_IFINAL-MAKTX = W_MAKT-MAKTX.           "Material Desp.
          ENDIF.
    * BASE UNIT OF MEASURE
          READ TABLE T_MARA INTO W_MARA
                            WITH KEY MATNR = W_MAIN-MATNR
                            BINARY SEARCH.
          IF SY-SUBRC = 0.
    *-----           Begin of Changes  EXT-SAP-180  13APR2007            ------*
            W_IFINAL-BSUOM = W_MARA-MEINS.
    *-----           End   of Changes  EXT-SAP-180  13APR2007            ------*
          ENDIF.
    * CONTRACT PRICE
          IF W_MAIN-PSTYP <> 2.
    * Assigning Scheduling agreement reference no. into agreement no.
            IF W_MAIN-AUTET EQ 2.
              W_MAIN-EBELN = W_MAIN-KONNR.
              W_MAIN-EBELP = W_MAIN-KTPNR.
            ENDIF.
    *-----           Begin of Changes  EXT-SAP-180  13APR2007            ------*
    * Assigning Purchase Order Unit of Measure
            W_IFINAL-PRUOM = W_MAIN-MEINS.
    *-----           Begin of Changes  EXT-SAP-180  13APR2007            ------*
    * Read conditon no. for agreement no.
            READ TABLE T_A016_C INTO W_A016_C
                                WITH KEY EVRTN = W_MAIN-EBELN
                                         EVRTP = W_MAIN-EBELP
                                BINARY SEARCH.
            IF SY-SUBRC = 0.
    *    Begin of insertion    EXT-SAP-180    02APR2007          *
              LOOP AT T_KONP_C INTO W_KONP_C
                               WHERE KNUMH = W_A016_C-KNUMH.
    *    End of insertion      EXT-SAP-180    02APR2007          *
    * to check scales
                READ TABLE T_KONM_C INTO W_KONM_C
                                  WITH KEY KNUMH = W_A016_C-KNUMH
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
                                           KOPOS = W_KONP_C-KOPOS
    *    End of Changes        EXT-SAP-180    02APR2007          *
                                  BINARY SEARCH.
                IF SY-SUBRC = 0.
    * Check Purchase order for Contract Price with scales
                  READ TABLE T_EKAB INTO W_EKAB
                                    WITH KEY KONNR = W_A016_C-EVRTN
                                             KTPNR = W_A016_C-EVRTP
                                    BINARY SEARCH.
                  IF SY-SUBRC = 0.
                    SORT T_KONM_C BY KNUMH KSTBM.
    * Get the Contract price, if Purchase order exist
                    LOOP AT T_KONM_C INTO W_KONM1
                                   WHERE KNUMH EQ W_A016_C-KNUMH
                                   AND   KSTBM LE W_EKAB-MENGE.
                      CLEAR L_KBETR.
                      IF SY-SUBRC = 0.
                        L_KBETR = W_KONM1-KBETR.
                        CONTINUE.
                      ENDIF.
                    ENDLOOP.
    * the above looping is done to get the right scale & stop, then add
    * the scale amount to the existing contract price in the below step.
                    W_IFINAL-CPRICE = W_IFINAL-CPRICE + L_KBETR.
                    CLEAR : W_KONM1,
                            L_KBETR.
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
                    SORT T_KONM_C BY KNUMH
                       KOPOS
                       KSTBM
                       DESCENDING.
    *    End of Changes        EXT-SAP-180    02APR2007          *
                  ELSE.
    * Get the Contract price, if doesnot Purchase order exist
                    W_IFINAL-CPRICE = W_IFINAL-CPRICE + W_KONM_C-KBETR. "Changed EXT-SAP-180 02APR2007
                  ENDIF.
                  CLEAR W_EKAB.
                ELSE.
    * Contract Price with out scales
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
                  READ TABLE T_KONP_C INTO W_KONP_C
                                      WITH KEY KNUMH = W_A016_C-KNUMH
                                               KSCHL = W_KONP_C-KSCHL
                                      BINARY SEARCH.
                  IF SY-SUBRC = 0.
                    W_IFINAL-CPRICE = W_IFINAL-CPRICE + W_KONP_C-KBETR.
                  ENDIF.
                  CLEAR W_KONP_C.
    *    End of Changes        EXT-SAP-180    02APR2007          *
                ENDIF.
                CLEAR W_KONM_C.
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
              ENDLOOP.
    *    End of Changes        EXT-SAP-180    02APR2007          *
    *----BEGIN OF CHANGE EXT-SAP-180  23rd April 2007
              L_CPRICE_C = W_IFINAL-CPRICE.
              CONDENSE L_CPRICE_C. "NO-GAPS.
              IF W_MAIN-PEINH IS INITIAL.
                W_IFINAL-FINCONPRI = L_CPRICE_C.
              ELSE.
                L_UNITPRICE_C = W_MAIN-PEINH.
                CONDENSE L_UNITPRICE_C. " NO-GAPS.
                CONCATENATE L_CPRICE_C '/' L_UNITPRICE_C W_MAIN-MEINS INTO W_IFINAL-FINCONPRI.
              ENDIF.
              CLEAR: L_CPRICE_C,
                     L_UNITPRICE_C.
    *----END   OF CHANGE EXT-SAP-180  23rd April 2007
            ENDIF.
            CLEAR W_A016_C.
          ENDIF.
    * PURCHASE INFO RECORD
          IF W_MAIN-PSTYP = 2.
    *-----           Begin of Changes  EXT-SAP-180  13APR2007            ------*
            READ TABLE T_EINE INTO W_EINE
                              WITH KEY INFNR = W_MAIN-INFNR
                                       EKORG = W_MAIN-EKORG
                                       WERKS = W_MAIN-WERKS
                              BINARY SEARCH.
            IF SY-SUBRC = 0.
              W_IFINAL-PRUOM = W_EINE-BPRME.
            ENDIF.
    *-----           End   of Changes  EXT-SAP-180  13APR2007            ------*
            READ TABLE T_A017_P INTO W_A017_P
                                WITH  KEY LIFNR = W_MAIN-LIFNR
                                          MATNR = W_MAIN-MATNR
                                          EKORG = W_MAIN-EKORG
                                          WERKS = W_MAIN-WERKS
                                BINARY SEARCH.
            IF SY-SUBRC = 0.
    * To check scales
              READ TABLE T_KONM_P INTO W_KONM_P
                                WITH KEY KNUMH = W_A017_P-KNUMH
                                BINARY SEARCH.
              IF SY-SUBRC = 0.
    * Check Purchase order for Purchase info record Price with scales
                READ TABLE T_EKPO INTO W_EKPO
                                  WITH KEY INFNR = W_MAIN-INFNR
                                  BINARY SEARCH.
                IF SY-SUBRC = 0.
                  SORT T_KONM_P BY KNUMH KSTBM.
    * Get the Pur.info rec. , if Purchase order exist
                  LOOP AT T_KONM_P INTO W_KONM2
                                 WHERE KNUMH EQ W_A017_P-KNUMH
                                 AND   KSTBM LE W_EKPO-MENGE.
                    W_IFINAL-INFOREC =  W_KONM2-KBETR.       "Pur.Info rec.
                  ENDLOOP.
                ELSE.
    * Get the Pur.info rec. price, if doesnot Purchase order exist
                  W_IFINAL-INFOREC = W_KONM_P-KBETR.         "Pur.Info rec.
                ENDIF.
              ELSE.
    * Get Pur.info rec. price,with out scales
                READ TABLE T_KONP_P INTO W_KONP_P
                                    WITH KEY KNUMH = W_A017_P-KNUMH
                                    BINARY SEARCH.
                IF SY-SUBRC = 0.
                  W_IFINAL-INFOREC = W_KONP_P-KBETR.         "Pur.Info rec.
                ENDIF.
              ENDIF.
            ENDIF.
    *----BEGIN OF CHANGE EXT-SAP-180  23rd April 2007
            L_CPRICE_I = W_IFINAL-INFOREC.
            CONDENSE L_CPRICE_I.
            IF W_EINE-PEINH IS INITIAL.
              W_IFINAL-FININFPRI = L_CPRICE_I.
            ELSE.
              L_UNITPRICE_I = W_EINE-PEINH.
              CONDENSE L_UNITPRICE_I. " NO-GAPS.
              CONCATENATE L_CPRICE_I '/' L_UNITPRICE_I W_EINE-BPRME INTO W_IFINAL-FININFPRI.
            ENDIF.
            W_MAIN-PEINH = W_EINE-PEINH.
            CLEAR: L_CPRICE_I,
                   L_UNITPRICE_I,
                   W_EINE,
                   W_KONM2,
                   W_KONP_P,
                   W_EKPO,
                   W_KONM_P,
                   W_A017_P.
    *--------End of Change EXT-SAP-180 23rd April 2007
          ENDIF.
    * MARKET PRICE
    *  Begin of Changes  CON-SAP-99  11/12/2006                            *
    *clear
          CLEAR : L_PERPRICE.
    *  End of Changes  CON-SAP-99  11/12/2006                              *
          IF W_IFINAL-CPRICE IS NOT INITIAL.
            L_PERPRICE = W_IFINAL-CPRICE.
          ELSE.
            L_PERPRICE = W_IFINAL-INFOREC.
          ENDIF.
          L_PERUNIT  = W_MAIN-PEINH. " fetching the unit at contract/inforecord price level
    *  Begin of Changes  CON-SAP-99  11/12/2006                            *
          W_IFINAL-MPRICE = L_PERPRICE.
    *    Begin of Changes      EXT-SAP-180    02APR2007          *
          CLEAR W_A049_T.
          SORT T_A049 BY EKORG MATNR.
          READ TABLE T_A049 INTO W_A049_T
                         WITH KEY EKORG = W_MAIN-EKORG
                                  MATNR = W_MAIN-MATNR
                         BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            CLEAR: W_A049_T.
            SORT T_KONP_M BY KNUMH.
            LOOP AT T_A049 INTO W_A049_T                        "03APR07
                           WHERE EKORG = W_MAIN-EKORG
                           AND   MATNR = W_MAIN-MATNR.
    * Following IF condition is to check whether the dates given in the selection criteria
    * are falling into the date ranges of the records of A049.
              IF ( W_A049_T-DATBI GE P_VDATE

  • Footer for ALV

    Hi,
    how we can create and display Footer for ALV Grid ,
    pls give me with some example

    Hi Chaaya,
    Here is the example.
    In the below code, TOP_OF_PAGE is used... similarly in your case END_OF_PAGE should be used. The way you define the event and handle it is similat to that of TOP_OF_PAGE event handled in the below code.
    * Description   : Automatic Condition records generation from Quotation*
    * Packages      : ZSPR                                                 *
    * Table Updates : VBAK, KONP and KONM                                  *
    * Parameters    : P_VKORG, P_VTWEG, P_SPART and P_VKAUS                *
    * Select Option : S_AUDAT, S_VBELN, S_KUNNR and S_MATNR                *
    * Input         : NA                                                   *
    * Output        : NA                                                   *
    * Return Codes  : SY-SUBRC                                             *
    * Special Logic : NA                                                   *
    * Includes      : NA                                                   *
    *             H I S T O R Y   O F   R E V I S I O N S                  *
    *  Date          Programmer      Request #        Description          *
    REPORT  ZSPRENH069 LINE-SIZE 1023 NO STANDARD PAGE HEADING.
    TYPE-POOLS : SLIS.                            "Global Type for ALV      
    *    T Y P E S                                                         *
    TYPES:
           BEGIN OF TY_VB_AKAP,
             VBELN      TYPE VBELN_VA,                       "Sales Document
             KUNNR      TYPE KUNAG,                          "Sold-to party
             POSNR      TYPE POSNR_VA,                       "Item Number
             MATNR      TYPE MATNR,                          "Material Number
             PMATN      TYPE PMATN,                          "Pricing Reference Material/Newly Created Material
             KWMENG     TYPE KWMENG,                         "Cumulative Order Qty. in Sales Units
             VRKME      TYPE VRKME,                          "Sales Unit
             KZWI1      TYPE KZWI1,                          "Sub Total 1 from pricing procedure for condition
             VKAUS      TYPE ABRVW,                          "Usage Indicator
             WAERK      TYPE WAERK,                          "SD Document Currency
           END   OF TY_VB_AKAP,
           BEGIN OF TY_MARA,
             MATNR      TYPE MATNR,                          "Material Number
             ZZTECHSPEC TYPE ZTECHSPEC,                      "Technical Specification
           END   OF TY_MARA,
           BEGIN OF TY_MVKE,
             MATNR      TYPE MATNR,                          "Material Number
             VKORG      TYPE VKORG,                          "Sales Organization
             VTWEG      TYPE VTWEG,                          "Distribution Channel
             KONDM      TYPE KONDM,                          "Material Pricing Group
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
             VRKME      TYPE VRKME,                          "Sales Unit according to the Material Master
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
           END   OF TY_MVKE,
           BEGIN OF TY_VBKD,
             VBELN      TYPE VBELN_VA,                       "Sales Document
             POSNR      TYPE POSNR_VA,                       "Item Number
             BSTKD_E    TYPE BSTKD_E,                        "Used to capture New Material Number
           END   OF TY_VBKD,
           BEGIN OF TY_IHEADER,
             SELECT(1)  TYPE C,                              "Check Box
             VBELN      TYPE VBELN,                          "Sales Document
             KUNNR      TYPE KUNAG,                          "Sold-to Party
           END   OF TY_IHEADER,
           BEGIN OF TY_MESSAGE1,
            VKORG     TYPE VKORG,                            "Sales Organization
            VTWEG     TYPE VTWEG,                            "Distribution Channel
            KUNNR     TYPE KUNAG,                            "Customer number
            KONDM     TYPE KONDM,                            "Material pricing group
            ZCOUNT(2) TYPE N,                                "Zcount
            MSGTYP(1) TYPE C,                                "Message type
            TEXT      TYPE STRING,                           "Message text
           END   OF TY_MESSAGE1,
    *-----------------Begin of changes for the change request 2007106------25th July 2007--------------------------------
           BEGIN OF TY_MESSAGE1_2,
            VKORG     TYPE VKORG,                            "Sales Organization
            VTWEG     TYPE VTWEG,                            "Distribution Channel
            KUNNR     TYPE KUNAG,                            "Customer number
            KONDM     TYPE KONDM,                            "Material pricin
            MSGTYP(1) TYPE C,                                "Message type
            TEXT      TYPE STRING,                           "Message text
           END   OF TY_MESSAGE1_2,
    *-----------------End   of changes for the change request 2007106------25th July 2007--------------------------------
           BEGIN OF TY_MESSAGE2,
            VKORG     TYPE VKORG,                            "Sales Organization
            VTWEG     TYPE VTWEG,                            "Distribution Channel
            KUNNR     TYPE KUNAG,                            "Customer number
            MATNR     TYPE MATNR,                            "Material Number
            MSGTYP(1) TYPE C,                                "Message type
            TEXT      TYPE STRING,                           "Message text
           END   OF TY_MESSAGE2,
           BEGIN OF TY_IFINAL,
             VBELN      TYPE VBELN_VA,                       "Sales Document
             KWMENG     TYPE KWMENG,                         "Cumulative Order Qty. in Sales Units
             POSNR      TYPE POSNR_VA,                       "Item Number
             KUNNR      TYPE KUNAG,                          "Sold-to party
             MATNR      TYPE MATNR,                          "Material Number
             VRKME      TYPE VRKME,                          "Sales Unit
             KZWI1      TYPE KZWI1,                          "Sub Total 1 from pricing procedure for condition
             VKAUS      TYPE ABRVW,                          "Usage Indicator
             ZZTECHSPEC TYPE ZTECHSPEC,                      "Technical Specification
             PMATN      TYPE PMATN,                          "Pricing Reference Material/Newly Created Material
             KONDM      TYPE KONDM,                          "Material Pricing Group
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
             WAERK      TYPE WAERK,                          "SD Document Currency
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
           END   OF TY_IFINAL,
           BEGIN OF TY_ACC1,
             VBELN      TYPE VBELN_VA,                       "Sales Document
             KUNNR      TYPE KUNAG,                          "Sold-to party
             KONDM      TYPE KONDM,                          "Material Pricing Group
             ZCOUNT(2)  TYPE N,                              "ZCount indicator
             KSTBM      TYPE KSTBM,                          "Quantity
             VRKME      TYPE VRKME,                          "Sales Unit
             ZZTECHSPEC TYPE ZTECHSPEC,                      "Technical Specification
             KZWI1      TYPE KZWI1,                          "Sub Total 1 from pricing procedure for condition
             ERROR(1)   TYPE N,                              "Error Field
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
             WAERK      TYPE WAERK,                          "SD Document Currency
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
           END   OF TY_ACC1,
    * Important Note : Earlier there were only three accesses and hence this below type was coded as TY_ACC2 depicting
    * the type for internal table as a holder of data for second access sequence, but later a new access sequence was
    * introduced and was introduced as the second access by itself and hence the sequence which was previously considered
    * as second access is going to be third access sequence in reality. The naming standards that are going to be followed
    * for the newly introduced access sequence would be XXX_1_2. (For Change request 2007106)
           BEGIN OF TY_ACC2,
             VBELN      TYPE VBELN_VA,                       "Sales Document
             KUNNR      TYPE KUNAG,                          "Sold-to party
             MATNR      TYPE MATNR,                          "Material Number
             KSTBM      TYPE KSTBM,                          "Cumulative Order Qty. in Sales Units
             ZZTECHSPEC TYPE ZTECHSPEC,                      "Technical Specification
             VRKME      TYPE VRKME,                          "Sales Unit
             KZWI1      TYPE KZWI1,                          "Sub Total 1 from pricing procedure for condition
             ERROR(1)   TYPE N,                              "Error field
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
             WAERK      TYPE WAERK,                          "SD Document Currency
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
           END   OF TY_ACC2,
    *-----------------Begin of changes for the change request 2007106------24th July 2007--------------------------------
           BEGIN OF TY_ACC1_2,
             VBELN      TYPE VBELN_VA,                       "Sales Document
             KUNNR      TYPE KUNAG,                          "Sold-to party
             KONDM      TYPE KONDM,                          "Material Pricing Group
             KSTBM      TYPE KSTBM,                          "Quantity
             VRKME      TYPE VRKME,                          "Sales Unit
             ZZTECHSPEC TYPE ZTECHSPEC,                      "Technical Specification
             KZWI1      TYPE KZWI1,                          "Sub Total 1 from pricing procedure for condition
             ERROR(1)   TYPE N,                              "Error field
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
             WAERK      TYPE WAERK,                          "SD Document Currency
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
           END   OF TY_ACC1_2,
    *-----------------End   of changes for the change request 2007106------24th July 2007--------------------------------
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
           BEGIN OF TY_T006,
             MSEHI      TYPE MSEHI,                          "Unit of Measurement
             ZAEHL      TYPE DZAEHL,                         "Numerator for conversion to SI unit
             NENNR      TYPE NENNR,                          "Denominator for conversion into SI unit
           END   OF TY_T006,
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
    *-----------------Begin of changes for the change request xxx------2nd Aug 2007--------------------------------
    *Types of MARM table
           BEGIN OF TY_MARM,
             MATNR TYPE MATNR,                               " Material Number
             MEINH TYPE LRMEI,                               " Alternative Unit of Measure
             UMREZ TYPE UMREZ,                               " Numerator for Conversion to Base UOM
             UMREN TYPE UMREN,                               " Denominator for Conversion to Base UOM
           END   OF TY_MARM.
    *-----------------End   of changes for the change request xxx------2nd Aug 2007--------------------------------
    *    D A T A                                                           *
    * Internal Table Declarations
    DATA: T_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV,           "Fieldcatalog IT
          T_EVENTS       TYPE SLIS_T_EVENT,                  "Event IT
          T_HEADER       TYPE SLIS_T_LISTHEADER,             "Header IT
          T_VB_AKAP      TYPE STANDARD TABLE OF TY_VB_AKAP,  "To hold records from VBAK & VBAP Table
          T_MARA         TYPE STANDARD TABLE OF TY_MARA,     "To hold records from MARA Table
          T_MVKE         TYPE STANDARD TABLE OF TY_MVKE,     "To hold records from MVKE Table
          T_VBKD         TYPE STANDARD TABLE OF TY_VBKD,     "To hold records from VBKD Table
          T_IHEADER      TYPE STANDARD TABLE OF TY_IHEADER,  "To hold records from VBAK Table
          T_IFINAL       TYPE STANDARD TABLE OF TY_IFINAL,   "To hold cumulative data for ALV
          T_BDCDATA      TYPE STANDARD TABLE OF BDCDATA,     "IT for bdcdata
          T_BDCMSGCOLL   TYPE STANDARD TABLE OF BDCMSGCOLL,  "IT for error messages
          T_MESSAGE1     TYPE STANDARD TABLE OF TY_MESSAGE1, "IT for conditions1 messages
    *-----------------Begin of changes for the change request 2007106------25th July 2007--------------------------------
          T_MESSAGE1_2   TYPE STANDARD TABLE OF TY_MESSAGE1_2,"ITfor conditions1_2 messages
    *-----------------End   of changes for the change request 2007106------25th July 2007--------------------------------
          T_MESSAGE2     TYPE STANDARD TABLE OF TY_MESSAGE2, "IT for conditions2 messages
          T_ACC2         TYPE STANDARD TABLE OF TY_ACC2,     "IT for holding data for Second Access Sequence Processing
          T_ACC1         TYPE STANDARD TABLE OF TY_ACC1,     "IT for holding data for First Access Sequence Processing
          T_SELECT       TYPE STANDARD TABLE OF RSPARAMS,    "IT for holding data related to the selection screen
    *-----------------Begin of changes for the change request 2007106------24th July 2007--------------------------------
          T_ACC1_2       TYPE STANDARD TABLE OF TY_ACC1_2,   "IT for holding data for new intermediate Access Sequence
    *-----------------End   of changes for the change request 2007106------24th July 2007--------------------------------
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
          T_T006         TYPE STANDARD TABLE OF TY_T006,     "IT for holding T006 Entries
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
    *-----------------Begin of changes for the change request xxx------2nd Aug 2007--------------------------------
          T_MARM         TYPE STANDARD TABLE OF TY_MARM,     "IT for holding entries from MARM
    *-----------------End   of changes for the change request xxx------2nd Aug 2007--------------------------------
    * Work area Declarations
          W_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV,             "Fieldcatalog WA
          W_EVENT        TYPE SLIS_ALV_EVENT,                "Event WA
          W_HEADER       TYPE SLIS_LISTHEADER,               "Header WA
          W_LAYOUT       TYPE SLIS_LAYOUT_ALV,               "Layout WA
          W_KEYINFO      TYPE SLIS_KEYINFO_ALV,              "Key Information WA
          W_VB_AKAP      TYPE TY_VB_AKAP,                    "To hold records from T_VB_AKAP
          W_MARA         TYPE TY_MARA,                       "To hold records from T_MARA
          W_MVKE         TYPE TY_MVKE,                       "To hold records from T_MVKE
          W_VBKD         TYPE TY_VBKD,                       "To hold records from T_VBKD
          W_IHEADER      TYPE TY_IHEADER,                    "To hold records from T_IHEADER
          W_IFINAL       TYPE TY_IFINAL,                     "To hold records from T_IFINAL
          W_PARAMS       TYPE CTU_PARAMS,                    "CTU Params
          W_BDCDATA      TYPE BDCDATA,                       "Work Area for BDCDATA
          W_BDCMSGCOLL   TYPE BDCMSGCOLL,                    "Work Area to collect BDC Messages
          W_MESSAGE1     TYPE TY_MESSAGE1,                   "WA for price conditions1 messages
    *-----------------Begin of changes for the change request 2007106------25th July 2007--------------------------------
          W_MESSAGE1_2   TYPE TY_MESSAGE1_2,                 "WA for price conditions1_2 messages
    *-----------------End   of changes for the change request 2007106------25th July 2007--------------------------------
          W_MESSAGE2     TYPE TY_MESSAGE2,                   "WA for price conditions2 messages
          W_ACC2         TYPE TY_ACC2,                       "WA for holding records from T_ACC2
          W_ACC1         TYPE TY_ACC1,                       "WA for holding records from T_ACC1
    *-----------------Begin of changes for the change request 2007106------24th July 2007--------------------------------
          W_ACC1_2       TYPE TY_ACC1_2,                     "WA for holding records from T_ACC1_2
    *-----------------End   of changes for the change request 2007106------24th July 2007--------------------------------
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
          W_T006         TYPE TY_T006,                       "WA for holding T_T006 Entries
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
    *-----------------Begin of changes for the change request xxx------2nd Aug 2007--------------------------------
          W_MARM         TYPE TY_MARM,                       "WA for holding entries of T_MARM
    *-----------------End   of changes for the change request xxx------2nd Aug 2007--------------------------------
    * Variable declarations
          G_VKORG       TYPE VKORG,                          "Sales Organization
          G_VTWEG       TYPE VTWEG,                          "Distribution Channel
          G_AUDAT       TYPE AUDAT,                          "Document Date (Date Received/Sent)
          G_VBELN       TYPE VBELN_VA,                       "Sales Document
          G_KUNNR       TYPE KUNAG,                          "Sold-to party
          G_MATNR       TYPE MATNR,                          "Material Number
          G_REPID       TYPE SY-REPID,                       "Program Name
          G_MESSAGE(73) TYPE C,                              "To Capture Message
          G_FLAG1(1)    TYPE C,                              "Flag
          G_ANSWER(1)   TYPE C,                              "Optional Button
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
          G_NUM_SOURCE  TYPE DZAEHL,                         "Holds Numerator value for Source Unit of Measure
          G_NUM_TARGET  TYPE DZAEHL,                         "Holds Numerator value for Target Unit of Measure
          G_DEN_SOURCE  TYPE NENNR,                          "Holds Denominator value for Source Unit of Measure
          G_DEN_TARGET  TYPE NENNR.                          "Holds Denominator value for Target Unit of Measure
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
    * Constant declarations
    CONSTANTS:
          C_A(1)         TYPE C VALUE 'A',                    "Constant Value A
          C_S(1)         TYPE C VALUE 'S',                    "Constant Value S
          C_U(1)         TYPE C VALUE 'U',                    "Constant Value U
          C_X(1)         TYPE C VALUE 'X',                    "Constant Value X
          C_E(1)         TYPE C VALUE 'E',                    "Constant Value E
          C_I(1)         TYPE C VALUE 'I',                    "Constant Value I
          C_R(1)         TYPE C VALUE 'R',                    "Constant Value R
          C_C(1)         TYPE C VALUE 'C',                    "Constant Value C
          C_B(1)         TYPE C VALUE 'B',                    "Document Category is Quotation
          C_HTNAME(10)   TYPE C VALUE 'T_IHEADER',            "Internal table for Header Data
          C_ITNAME(10)   TYPE C VALUE 'T_IFINAL',             "Internal Table with processed data
          C_Q2(2)        TYPE C VALUE 'Q2',                   "Constant Order Reason Q2
          C_100(3)       TYPE C VALUE '100',                  "Popup screen
          C_25(2)        TYPE C VALUE '25',                   "Popup screen
          C_5(1)         TYPE C VALUE '5',                    "Popup screen
          C_1            TYPE I VALUE  1,                     "Value 1 for Error Denotion
          C_2            TYPE I VALUE  2,                     "Value 2 for Error Denotion
          C_3            TYPE I VALUE  3,                     "Value 3 for BDC Error Denotion
          C_1000(4)      TYPE N VALUE 1000,                     "Value 1000
          C_01(2)        TYPE N VALUE '01',                   "Value 01 for Zcount
          C_VK11(4)      TYPE C VALUE 'VK11',                 "Transaction VK11
          C_DYNBEGIN(1)  TYPE C VALUE 'X',                    "Indicator
          C_UPDATE(1)    TYPE C VALUE 'S',                    "Update
          C_DISMODE(1)   TYPE C VALUE 'N',                    "Display
          C_Q3(2)        TYPE C VALUE 'Q3',                   "Quotation Approved
          C_ZBPR(4)      TYPE C VALUE 'ZBPR',                 "Condition Type ZBPR
    *-----------------Begin of changes for the change request xxx------2nd Aug 2007--------------------------------
          C_ZBPN(4)      TYPE C VALUE 'ZBPN',                 "Condition Type ZBPN
    *-----------------End   of changes for the change request xxx------2nd Aug 2007--------------------------------
          C_ERROR(5)     TYPE C VALUE 'ERROR'.                "Error screen title
    *    S E L E C T   O P T I O N S  &  P A R A M E T E R S               *
    * Selection-screen Block 1
    SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
    PARAMETERS:     P_VKORG TYPE VKORG OBLIGATORY,           "Sales Organization
                    P_VTWEG TYPE VTWEG OBLIGATORY,           "Distribution Channel
                    P_SPART TYPE SPART DEFAULT '00'.         "Division
    SELECTION-SCREEN END OF BLOCK BLK1.
    SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-002.
    SELECT-OPTIONS: S_AUDAT FOR G_AUDAT,                     "Document Date (Date Received/Sent)
                    S_VBELN FOR G_VBELN,                     "Sales Document
                    S_KUNNR FOR G_KUNNR,                     "Sold-to party
                    S_MATNR FOR G_MATNR.                     "Material Number
    PARAMETERS:     P_VKAUS(2) TYPE N.                       "Usage Indicator
    SELECTION-SCREEN END OF BLOCK BLK2.
    *   I N I T I A L I Z A T I O N                                        *
    INITIALIZATION.
      CLEAR : G_REPID.                                       "Program Name
      G_REPID = SY-REPID.                                    "Program Name
    *   A T   S E L E C T I O N   S C R E E N                              *
      CLEAR: G_VKORG,
             G_VTWEG.
    AT SELECTION-SCREEN ON P_VKORG.
      SELECT SINGLE VKORG INTO G_VKORG
                          FROM TVKO
                          WHERE VKORG EQ P_VKORG.
      IF SY-SUBRC NE 0.
        MESSAGE E000(ZS) WITH TEXT-021.
      ENDIF.
    AT SELECTION-SCREEN ON P_VTWEG.
      SELECT SINGLE VTWEG INTO G_VTWEG
                          FROM TVKOV
                          WHERE VKORG EQ P_VKORG
                            AND VTWEG EQ P_VTWEG.
      IF SY-SUBRC NE 0.
        MESSAGE E000(ZS) WITH TEXT-022.
      ENDIF.
      CLEAR: G_VKORG,
             G_VTWEG.
    *   S T A R T   O F   S E L E C T I O N                                *
    START-OF-SELECTION.
    * Data Selection
      PERFORM DATA_RETRIEVAL.
    * Build Field Catalog
      PERFORM BUILD_FIELDCATALOG.
    * Bulid layout
      PERFORM BUILD_LAYOUT.
    * Build Events
      PERFORM BUILD_EVENTS.
    * Captures the Values of Selection Screen
      PERFORM CAPTURE_SCREEN.
    *   E N D   O F   S E L E C T I O N                                    *
    END-OF-SELECTION.
    * Display List
      PERFORM DISPLAY_ALV_REPORT.
    *   F O R M S                                                          *
    *&      Form  DATA_RETRIEVAL
    *       Retrieves Data for ALV Display
    *-----------------Begin of changes for the change request 2007106------25th July 2007--------------------------------
    *-----------------End   of changes for the change request 2007106------25th July 2007--------------------------------
    FORM DATA_RETRIEVAL .
      DATA : L_VKAUS   TYPE VKAUS.            "Variable to hold Usage Indicator
      CLEAR L_VKAUS.
      SELECT VBELN
             KUNNR
        INTO CORRESPONDING FIELDS OF TABLE T_IHEADER
        FROM VBAK
        WHERE VBELN IN S_VBELN
          AND KUNNR IN S_KUNNR
          AND VKORG EQ P_VKORG
          AND AUDAT IN S_AUDAT
          AND VTWEG EQ P_VTWEG
          AND SPART EQ P_SPART
          AND AUGRU EQ C_Q2
          AND VBTYP EQ C_B.
      IF NOT T_IHEADER IS INITIAL.
        IF NOT P_VKAUS IS INITIAL.
    *-----------------Begin of changes for the change request 2007106------25th July 2007------COMMENTED FROM HERE-----
    *      IF P_VKAUS EQ C_1.    "IF Zcount is given as 1 then quotation without zcount should be picked
    *        "for whom Material Pricing Group should be given.
    *        SELECT A~VBELN
    *               A~KUNNR
    *               B~POSNR
    *               B~MATNR
    *               B~PMATN
    *               B~KWMENG
    *               B~VRKME
    *               B~KZWI1
    *               B~VKAUS
    *         INTO  TABLE T_VB_AKAP
    *         FROM  VBAK AS A
    *         JOIN  VBAP AS B
    *           ON  A~VBELN EQ B~VBELN
    *         FOR ALL ENTRIES IN T_IHEADER
    *         WHERE A~VBELN EQ T_IHEADER-VBELN
    *           AND B~MATNR IN S_MATNR.
    *      ELSE.
    *-----------------End   of changes for the change request 2007106------25th July 2007------COMMENTED TILL HERE-----
          CONCATENATE C_C P_VKAUS INTO L_VKAUS.
          SELECT A~VBELN
                 A~KUNNR
                 B~POSNR
                 B~MATNR
                 B~PMATN
                 B~KWMENG
                 B~VRKME
                 B~KZWI1
                 B~VKAUS
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
                 A~WAERK
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
           INTO  TABLE T_VB_AKAP
           FROM  VBAK AS A
           JOIN  VBAP AS B
             ON  A~VBELN EQ B~VBELN
           FOR ALL ENTRIES IN T_IHEADER
            WHERE A~VBELN EQ T_IHEADER-VBELN
              AND B~MATNR IN S_MATNR
              AND B~VKAUS EQ L_VKAUS.
    *      ENDIF.
        ELSE.
          SELECT A~VBELN
                 A~KUNNR
                 B~POSNR
                 B~MATNR
                 B~PMATN
                 B~KWMENG
                 B~VRKME
                 B~KZWI1
                 B~VKAUS
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
                 A~WAERK
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
           INTO  TABLE T_VB_AKAP
           FROM  VBAK AS A
           JOIN  VBAP AS B
             ON  A~VBELN EQ B~VBELN
           FOR ALL ENTRIES IN T_IHEADER
           WHERE A~VBELN EQ T_IHEADER-VBELN
             AND B~MATNR IN S_MATNR.
        ENDIF.
        IF NOT T_VB_AKAP IS INITIAL.
          SELECT  VBELN
                  POSNR
                  BSTKD_E
             INTO TABLE T_VBKD
             FROM VBKD
             FOR ALL ENTRIES IN T_VB_AKAP
             WHERE VBELN EQ T_VB_AKAP-VBELN
               AND POSNR EQ T_VB_AKAP-POSNR.
        ENDIF.
        SORT T_VBKD BY VBELN POSNR.
        CLEAR W_VB_AKAP.
    *   After much of coding was completed, Usage of PMATN was dropped and
    *   the first eighteen characters of the field BSTKD was proposed for usage
    *   Hence PMATN is overwritten by BSTKD value in the below loop
        LOOP AT T_VB_AKAP INTO W_VB_AKAP.
          CLEAR: W_VBKD,
                 W_VB_AKAP-PMATN.
          READ TABLE T_VBKD INTO W_VBKD
                            WITH KEY VBELN = W_VB_AKAP-VBELN
                                     POSNR = W_VB_AKAP-POSNR
                            BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            W_VB_AKAP-PMATN = W_VBKD-BSTKD_E+0(18).
          ENDIF.
          MODIFY T_VB_AKAP FROM W_VB_AKAP TRANSPORTING PMATN.
          CLEAR W_VB_AKAP.
        ENDLOOP.
        IF NOT T_VB_AKAP IS INITIAL.
    *     Collecting all Material Numbers along with their Technical Spec data for all the materials available in T_VB_AKAP.
          SELECT    MATNR
                    ZZTECHSPEC
            INTO    TABLE T_MARA
            FROM    MARA
            FOR ALL ENTRIES IN T_VB_AKAP
            WHERE   MATNR EQ T_VB_AKAP-MATNR.
          IF SY-SUBRC EQ 0.
            SORT T_MARA BY MATNR.
          ENDIF.                     "Checking SY-SUBRC for T_MARA
          SELECT    MATNR
                    ZZTECHSPEC
            APPENDING TABLE T_MARA
            FROM    MARA
            FOR ALL ENTRIES IN T_VB_AKAP
            WHERE   MATNR EQ T_VB_AKAP-PMATN.
          IF SY-SUBRC EQ 0.
            SORT T_MARA BY MATNR.
          ENDIF.                     "Checking SY-SUBRC for T_MARA
    *-----------------Begin of changes for the change request xxx------2nd Aug 2007--------------------------------
    *     Collecting information into T_MARM for all the available materials so that it could be used for conversion into Alternate UOM
          SELECT MATNR                          " Material Number
                 MEINH                          " Alternate UOM
                 UMREZ                          " Numerator for conversion
                 UMREN                          " Denominator for conversion
            FROM MARM
            INTO TABLE T_MARM
            FOR ALL ENTRIES IN T_VB_AKAP
            WHERE MATNR EQ T_VB_AKAP-MATNR.
          IF SY-SUBRC = 0.
            SORT T_MARM BY MATNR MEINH.
          ENDIF.                     "Checking SY-SUBRC for T_MARM
          SELECT MATNR                          " Material Number
                 MEINH                          " Alternate UOM
                 UMREZ                          " Numerator for conversion
                 UMREN                          " Denominator for conversion
            FROM MARM
            APPENDING TABLE T_MARM
            FOR ALL ENTRIES IN T_VB_AKAP
            WHERE MATNR EQ T_VB_AKAP-PMATN.
          IF SY-SUBRC = 0.
            SORT T_MARM BY MATNR MEINH.
          ENDIF.                     "Checking SY-SUBRC for T_MARM
    *-----------------End   of changes for the change request xxx------2nd Aug 2007--------------------------------
          SELECT    MATNR
                    VKORG
                    VTWEG
                    KONDM
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
                    VRKME
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
            INTO    TABLE T_MVKE
            FROM    MVKE
            FOR ALL ENTRIES IN T_VB_AKAP
            WHERE   MATNR EQ T_VB_AKAP-PMATN.
          IF SY-SUBRC EQ 0.
            SORT T_MVKE BY MATNR VKORG VTWEG.
          ENDIF.                     "Checking SY-SUBRC for T_MVKE
          SELECT    MATNR
                    VKORG
                    VTWEG
                    KONDM
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
                    VRKME
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
            APPENDING TABLE T_MVKE
            FROM    MVKE
            FOR ALL ENTRIES IN T_VB_AKAP
            WHERE   MATNR EQ T_VB_AKAP-MATNR.
          IF SY-SUBRC EQ 0.
            SORT T_MVKE BY MATNR VKORG VTWEG.
          ENDIF.                     "Checking SY-SUBRC for T_MVKE
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
          SELECT    MSEHI
                    ZAEHL
                    NENNR
             INTO   TABLE T_T006
             FROM   T006
             FOR ALL ENTRIES IN T_VB_AKAP
             WHERE  MSEHI EQ T_VB_AKAP-VRKME.
          IF SY-SUBRC EQ 0.
            SORT T_T006 BY MSEHI.
          ENDIF.                     "Checking SY-SUBRC for T_T006
          IF NOT T_MVKE IS INITIAL.
            SELECT MSEHI
                   ZAEHL
                   NENNR
            APPENDING TABLE T_T006
            FROM   T006
            FOR ALL ENTRIES IN T_MVKE
            WHERE MSEHI EQ T_MVKE-VRKME.
            IF SY-SUBRC EQ 0.
              SORT T_T006 BY MSEHI.
            ENDIF.                  "Checking SY-SUBRC for T_T006
          ENDIF.                     "Checking for Initial status of internal table T_MVKE
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
        ENDIF.                    " FOR T_VB_AKAP NOT INITIAL.
      ENDIF.                    " FOR T_IHEADER NOT INITIAL.
      CLEAR: W_VB_AKAP,
             W_IFINAL.
      LOOP AT T_VB_AKAP INTO W_VB_AKAP.
        W_IFINAL-VBELN  = W_VB_AKAP-VBELN.
        W_IFINAL-KUNNR  = W_VB_AKAP-KUNNR.
        W_IFINAL-POSNR  = W_VB_AKAP-POSNR.
        W_IFINAL-MATNR  = W_VB_AKAP-MATNR.
        W_IFINAL-PMATN  = W_VB_AKAP-PMATN.
        W_IFINAL-KWMENG = W_VB_AKAP-KWMENG.
        W_IFINAL-VRKME  = W_VB_AKAP-VRKME.
        W_IFINAL-KZWI1  = ( W_VB_AKAP-KZWI1 / W_VB_AKAP-KWMENG ) * 1000.
        W_IFINAL-VKAUS  = W_VB_AKAP-VKAUS.
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
        W_IFINAL-WAERK  = W_VB_AKAP-WAERK.
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
    *   Populating Material Pricing Group from New Material Group, if such Group doesn't exist
    *   Population of Material Pricing Group from Material Number is tried.
    *   Similar condition does suit for Tech Spec too.
        SORT: T_MVKE BY MATNR VKORG VTWEG,
              T_MARA BY MATNR.
        IF NOT W_VB_AKAP-PMATN IS INITIAL.
          CLEAR W_MVKE.
          READ TABLE    T_MVKE
               INTO     W_MVKE
               WITH KEY MATNR = W_VB_AKAP-PMATN
                        VKORG = P_VKORG
                        VTWEG = P_VTWEG
               BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            W_IFINAL-KONDM = W_MVKE-KONDM.
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
            IF ( W_IFINAL-VRKME NE W_MVKE-VRKME ) AND ( NOT W_MVKE-VRKME IS INITIAL ).
    *-----------------Begin of changes for the change request xxx------2nd Aug 2007--------------------------------
              CLEAR: W_MARM,
                     G_NUM_SOURCE,
                     G_DEN_SOURCE,
                     G_NUM_TARGET,
                     G_DEN_TARGET.
              READ TABLE T_MARM INTO W_MARM
                                WITH KEY MATNR = W_IFINAL-PMATN
                                MEINH = W_IFINAL-VRKME
                                BINARY SEARCH.
              IF SY-SUBRC EQ 0.
                G_NUM_SOURCE = W_MARM-UMREZ.
                G_DEN_SOURCE = W_MARM-UMREN.
                CLEAR W_MARM.
                READ TABLE T_MARM INTO W_MARM
                                  WITH KEY MATNR = W_IFINAL-PMATN
                                  MEINH = W_MVKE-VRKME
                                  BINARY SEARCH.
                IF SY-SUBRC EQ 0.
                  G_NUM_TARGET = W_MARM-UMREZ.
                  G_DEN_TARGET = W_MARM-UMREN.
                  CLEAR W_MARM.
                  W_IFINAL-KWMENG = W_IFINAL-KWMENG * ( G_NUM_SOURCE / G_DEN_SOURCE ) * ( G_DEN_TARGET / G_NUM_TARGET ).
                  CLEAR W_IFINAL-KZWI1.
                  W_IFINAL-KZWI1   = ( W_VB_AKAP-KZWI1 / W_IFINAL-KWMENG ) * 1000.
                  W_IFINAL-VRKME = W_MVKE-VRKME.
                ENDIF.              "Check SY-SUBRC for W_MARM using W_MVKE-VRKME (Sales UOM)
              ELSE.
    *-----------------End   of changes for the change request xxx------2nd Aug 2007--------------------------------
                CLEAR: W_T006,
                       G_NUM_SOURCE,
                       G_DEN_SOURCE,
                       G_NUM_TARGET,
                       G_DEN_TARGET.
                READ TABLE T_T006 INTO W_T006 WITH KEY MSEHI = W_IFINAL-VRKME
                                              BINARY SEARCH.
                IF SY-SUBRC EQ 0.
                  G_NUM_SOURCE = W_T006-ZAEHL.          "Numerator to convert specified UOM to SI UOM
                  G_DEN_SOURCE = W_T006-NENNR.          "Denominator to convert specified UOM to SI UOM
                  CLEAR W_T006.
                  READ TABLE T_T006 INTO W_T006 WITH KEY MSEHI = W_MVKE-VRKME
                                                BINARY SEARCH.
                  IF SY-SUBRC EQ 0.
                    G_NUM_TARGET = W_T006-ZAEHL.            "Numerator to convert specified UOM to SI UOM
                    G_DEN_TARGET = W_T006-NENNR.            "Denominator to convert specified UOM to SI UOM
                    CLEAR W_T006.
                    W_IFINAL-KWMENG = W_IFINAL-KWMENG * ( G_NUM_SOURCE / G_DEN_SOURCE ) * ( G_DEN_TARGET / G_NUM_TARGET ).
                    CLEAR W_IFINAL-KZWI1.
                    W_IFINAL-KZWI1   = ( W_VB_AKAP-KZWI1 / W_IFINAL-KWMENG ) * 1000.
                    W_IFINAL-VRKME = W_MVKE-VRKME.
                  ENDIF.          "Check for SY-SUBRC for READ TABLE T_T006 using W_MVKE-VRKME (Sales UOM)
                ENDIF.            "Check for SY-SUBRC for READ TABLE T_T006 using W_IFINAL-VRKME (Quotation UOM)
              ENDIF.              "Check SY-SUBRC for W_MARM using W_IFINAL-VRKME (Quotation UOM)
            ENDIF.              "Check for ( W_IFINAL-VRKME NE W_MVKE-VRKME ) AND ( NOT W_MVKE-VRKME IS INITIAL )
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
          ENDIF.
          CLEAR W_MARA.
          READ TABLE     T_MARA
               INTO      W_MARA
               WITH KEY  MATNR = W_VB_AKAP-PMATN
               BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            W_IFINAL-ZZTECHSPEC = W_MARA-ZZTECHSPEC.
          ENDIF.                              " SY-SUBRC FOR READ TABLE T_MARA
        ELSE.
          CLEAR W_MVKE.
          READ TABLE     T_MVKE
               INTO      W_MVKE
               WITH KEY  MATNR = W_VB_AKAP-MATNR
                         VKORG = P_VKORG
                         VTWEG = P_VTWEG
               BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            W_IFINAL-KONDM = W_MVKE-KONDM.
    *-----------------Begin of changes for the change request 2007096------26th July 2007--------------------------------
            IF ( W_IFINAL-VRKME NE W_MVKE-VRKME ) AND ( NOT W_MVKE-VRKME IS INITIAL ).
    *-----------------Begin of changes for the change request xxx------2nd Aug 2007--------------------------------
              CLEAR: W_MARM,
                     G_NUM_SOURCE,
                     G_DEN_SOURCE,
                     G_NUM_TARGET,
                     G_DEN_TARGET.
              READ TABLE T_MARM INTO W_MARM
                                WITH KEY MATNR = W_IFINAL-MATNR
                                MEINH = W_IFINAL-VRKME
                                BINARY SEARCH.
              IF SY-SUBRC EQ 0.
                G_NUM_SOURCE = W_MARM-UMREZ.
                G_DEN_SOURCE = W_MARM-UMREN.
                CLEAR W_MARM.
                READ TABLE T_MARM INTO W_MARM
                                  WITH KEY MATNR = W_IFINAL-MATNR
                                  MEINH = W_MVKE-VRKME
                                  BINARY SEARCH.
                IF SY-SUBRC EQ 0.
                  G_NUM_TARGET = W_MARM-UMREZ.
                  G_DEN_TARGET = W_MARM-UMREN.
                  CLEAR W_MARM.
                  W_IFINAL-KWMENG = W_IFINAL-KWMENG * ( G_NUM_SOURCE / G_DEN_SOURCE ) * ( G_DEN_TARGET / G_NUM_TARGET ).
                  CLEAR W_IFINAL-KZWI1.
                  W_IFINAL-KZWI1   = ( W_VB_AKAP-KZWI1 / W_IFINAL-KWMENG ) * 1000.
                  W_IFINAL-VRKME = W_MVKE-VRKME.
                ENDIF.              "Check SY-SUBRC for W_MARM using W_MVKE-VRKME (Sales UOM)
              ELSE.
    *-----------------End   of changes for the change request xxx------2nd Aug 2007--------------------------------
                CLEAR: W_T006,
                       G_NUM_SOURCE,
                       G_DEN_SOURCE,
                       G_NUM_TARGET,
                       G_DEN_TARGET.
                READ TABLE T_T006 INTO W_T006 WITH KEY MSEHI = W_IFINAL-VRKME
                                              BINARY SEARCH.
                IF SY-SUBRC EQ 0.
                  G_NUM_SOURCE = W_T006-ZAEHL.          "Numerator to convert specified UOM to SI UOM
                  G_DEN_SOURCE = W_T006-NENNR.          "Denominator to convert specified UOM to SI UOM
                  CLEAR W_T006.
                  READ TABLE T_T006 INTO W_T006 WITH KEY MSEHI = W_MVKE-VRKME
                                                BINARY SEARCH.
                  IF SY-SUBRC EQ 0.
                    G_NUM_TARGET = W_T006-ZAEHL.            "Numerator to convert specified UOM to SI UOM
                    G_DEN_TARGET = W_T006-NENNR.            "Denominator to convert specified UOM to SI UOM
                    CLEAR W_T006.
                    W_IFINAL-KWMENG = W_IFINAL-KWMENG * ( G_NUM_SOURCE / G_DEN_SOURCE ) * ( G_DEN_TARGET / G_NUM_TARGET ).
                    CLEAR W_IFINAL-KZWI1.
                    W_IFINAL-KZWI1   = ( W_VB_AKAP-KZWI1 / W_IFINAL-KWMENG ) * 1000.
                    W_IFINAL-VRKME = W_MVKE-VRKME.
                  ENDIF.          "Check for SY-SUBRC for READ TABLE T_T006 using W_MVKE-VRKME (Sales UOM)
                ENDIF.            "Check for SY-SUBRC for READ TABLE T_T006 using W_IFINAL-VRKME (Quotation UOM)
              ENDIF.              "Check SY-SUBRC for W_MARM using W_IFINAL-VRKME (Quotation UOM)
            ENDIF.              "Check for ( W_IFINAL-VRKME NE W_MVKE-VRKME ) AND ( NOT W_MVKE-VRKME IS INITIAL )
    *-----------------End   of changes for the change request 2007096------26th July 2007--------------------------------
          ENDIF.
          CLEAR W_MARA.
          READ TABLE     T_MARA
               INTO      W_MARA
               WITH KEY  MATNR = W_VB_AKAP-MATNR
               BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            W_IFINAL-ZZTECHSPEC = W_MARA-ZZTECHSPEC.
          ENDIF.                              " SY-SUBRC FOR READ TABLE T_MARA
        ENDIF.                              " IS INITIAL CHECK FOR W_MVKE-KONDM
    *-----------------Begin of changes for the change request 2007106------25th July 2007------COMMENTED FROM HERE-----
    **   This logic is written to avoid records without Material Pricing group whose
    **   Zcount is selected as 1.
    *    IF P_VKAUS EQ C_1.
    *      IF NOT W_IFINAL-KONDM IS INITIAL AND W_IFINAL-VKAUS IS INITIAL.
    *        APPEND W_IFINAL TO T_IFINAL.
    *      ENDIF.
    *    ELSE.
    *-----------------End   of changes for the change request 2007106------25th July 2007------COMMENTED TILL HERE-----
        APPEND W_IFINAL TO T_IFINAL.
    *    ENDIF.              Commented for the change request 2007106-----25th July 2007
        CLEAR: W_VB_AKAP,
               W_IFINAL.
      ENDLOOP.
      SORT T_IFINAL BY VBELN POSNR.
    *  Checking whether if there are any header quotations which does not have items against them in item internal table
    *  if such records exist then, ensuring that such records gets deleted from header too, so that inconsitency is removed.
      CLEAR W_IHEADER.
      LOOP AT T_IHEADER INTO W_IHEADER.
        CLEAR W_IFINAL.
        READ TABLE T_IFINAL INTO W_IFINAL
                            WITH KEY VBELN = W_IHEADER-VBELN
                            BINARY SEARCH.
        IF SY-SUBRC NE 0.
          W_IHEADER-SELECT = C_X.
          MODIFY T_IHEADER FROM W_IHEADER TRANSPORTING SELECT.
        ENDIF.
      ENDLOOP.
      DELETE T_IHEADER WHERE SELECT = C_X.
      SORT T_IFINAL BY VBELN POSNR.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  build_layout
    *       To build ALV Layout
    FORM BUILD_LAYOUT.
      CLEAR  : W_LAYOUT.
      W_LAYOUT-COLWIDTH_OPTIMIZE = C_X.
      W_LAYOUT-BOX_TABNAME       = C_HTNAME.      "tabname for checkbox
      W_LAYOUT-BOX_FIELDNAME     = 'SELECT'.      "fieldname for checkbox
      CLEAR  : W_KEYINFO.
      W_KEYINFO-HEADER01 = 'VBELN'.               "Header1 key information
      W_KEYINFO-ITEM01   = 'VBELN'.               "Item1 key information
    *  W_LAYOUT-no_min_linesize = C_X.
    *         W_LAYOUT-min_linesize  = 80.
    *         W_LAYOUT-max_linesize  = 400.
    ENDFORM.                                      "build_layout
    *&      Form  build_events
    *       To build ALV Events
    FORM BUILD_EVENTS.
      CONSTANTS: C_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          I_LIST_TYPE     = 1
        IMPORTING
          ET_EVENTS       = T_EVENTS
        EXCEPTIONS
          LIST_TYPE_WRONG = 1
          OTHERS          = 2.
      IF SY-SUBRC = 0.
        CLEAR W_EVENT.
        READ TABLE T_EVENTS INTO W_EVENT
                            WITH KEY NAME = C_TOP_OF_PAGE.
        IF SY-SUBRC = 0.
          MOVE C_TOP_OF_PAGE TO W_EVENT-FORM.
          MODIFY T_EVENTS INDEX SY-TABIX
                          FROM  W_EVENT
                          TRANSPORTING FORM.
        ENDIF.
      ELSE.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                                      "build_events
    *&      Form  top_of_page
    *       To display top of page in ALV Report
    FORM TOP_OF_PAGE.                                           "#EC CALLED
      DATA :
        L_VKORG(35) TYPE C,                        "Sales Organization
        L_VTWEG(35) TYPE C,                        "Distribution Channel
        L_SPART(35) TYPE C.                        "Division
    * Sales Organization
      CLEAR W_HEADER.
      W_HEADER-TYP  = C_S.
      CONCATENATE TEXT-004 P_VKORG INTO L_VKORG.
      W_HEADER-INFO = L_VKORG.
      APPEND W_HEADER TO T_HEADER.
    * Distribution Channel
      CLEAR W_HEADER.
      W_HEADER-TYP  = C_S.
      CONCATENATE TEXT-005 P_VTWEG INTO L_VTWEG.
      W_HEADER-INFO = L_VTWEG.
      APPEND W_HEADER TO T_HEADER.
    * Division
      CLEAR W_HEADER.
      W_HEADER-TYP  = C_S.
      CONCATENATE TEXT-006 P_SPART INTO L_SPART.
      W_HEADER-INFO = L_SPART.
      APPEND W_HEADER TO T_HEADER.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY = T_HEADER.
    ENDFORM.                                      "top_of_page
    *&      Form  pf_status
    *       To set PF-Status (user interface)
    *      -->EXTAB     The excluding table (function codes)
    FORM PF_STATUS                                              "#EC CALLED
              USING T_EXTAB TYPE SLIS_T_EXTAB.
      REFRESH T_EXTAB.
      SET PF-STATUS 'ZSTANDARD_FULLSCREEN' EXCLUDING T_EXTAB.
    ENDFORM.                                      "pf_status
    *&      Form  display_alv_report
    *       To display ALV report
    FORM DISPLAY_ALV_REPORT.
      CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM       = G_REPID
          I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
          I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
          IS_LAYOUT                = W_LAYOUT
          IT_FIELDCAT              = T_FIELDCATALOG
          I_DEFAULT                = C_X
          I_SAVE                   = C_A
          IT_EVENTS                = T_EVENTS[]
          I_TABNAME_HEADER         = 'T_IHEADER'
          I_TABNAME_ITEM           = 'T_IFINAL'
          IS_KEYINFO               = W_KEYINFO
        TABLES
          T_OUTTAB_HEADER          = T_IHEADER
          T_OUTTAB_ITEM            = T_IFINAL
        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.                                      "display_alv_report
    *&      Form  BUILD_FIELDCATALOG
    *       To build ALV Field Catalog
    FORM BUILD_FIELDCATALOG .
      DATA: L_COUNT TYPE I VALUE 0.
      CLEAR  W_FIELDCATALOG.
      L_COUNT = L_COUNT + 1.
      W_FIELDCATALOG-COL_POS     =  L_COUNT.
      W_FIELDCATALOG-TABNAME     =  C_HTNAME.
      W_FIELDCATALOG-FIELDNAME   = 'SELECT'.
      W_FIELDCATALOG-SELTEXT_M   =  TEXT-C01.
      W_FIELDCATALOG-CHECKBOX    =  C_X.
      W_FIELDCATALOG-EDIT        =  C_X.
      APPEND W_FIELDCATALOG TO T_FIELDCATALOG.
      CLEAR  W_FIELDCATALOG.
      L_COUNT = L_COUNT + 1.
      W_FIELDCATALOG-COL_POS     =  L_COUNT.
      W_FIELDCATALOG-TABNAME     =  C_HTNAME.
      W_FIELDCATALOG-FIELDNAME   = 'VBELN'.
      W_FIELDCATALOG-SELTEXT_M   =  TEXT-C02.
      W_FIELDCATALOG-KEY         =  C_X.   "Fixes the column for no-scroll
      APPEND W_FIELDCATALOG TO T_FIELDCATALOG.
      CLEAR  W_FIELDCATALOG.
      L_COUNT = L_COUNT + 1.
      W_FIELDCATALOG-COL_POS 

Maybe you are looking for