Program Structure for PID temperature Controller

Hi everybody,
I built a PID temperature controller VI for a third party DAQ board, based on a very basic knowledge in programming.
Now the VI works fine in both ends "i/ps & o/ps", the problem is that i cant get the response that I'm looking for from the PID controller. Since the system is time critical, I wounder if the structure of the VI is cosing this problem. please if you have any idea, hint or suggestion.
Marwan
http://www.geocities.com/marwan_m13/weemee8080.jpg
Attachments:
PIC Temperature Control(PID).vi ‏364 KB

Marwan,
You say that time is critical. The timeout is set to 1 second in the main loop. You will only get one update per second with this setting.
Several comments:
1. I have never seen the event structure used soley to control loop timing like this. No reason it should not work, but that is not its primary purpose. If you were to use the event structure to also handle user events (as it is designed to do), then things could get complicated. The Wait (ms) functions and Elapsed Time Express VIs can perform the timing for you without the risk of unintended consequences.
2. Generally it is recommended to use only one event structure in a program, unless you have very specific reasons for using more than one. Since you are using them only as timers, the interaction potential is minimal.
3. Right to left wiring and avoidance of wires hidden behind other objects make code much easier to read and to debug.
4. Putting the user controls and displays and the write to file functions in independent loops allows the PID function to run at different rates from the user interface and file save functions. Look at examples of Producer/consumer architecture.
5. Precalculating things which do not change from iteration to iteration can save time. For example multiply by 2.55 rather than multiply by 255 and divide by 100. Also make the datatypes consistent to avoid type coercion (indicated by little dots at the input connections such as the 255 input to the mutliply. Changing the datatype of the 255 constant to Double eliminates the coercion.
Lynn

Similar Messages

  • PID Temperature Controller with myRIO

    I am interested in implementing the LabVIEW PID VI to create a temperature controller using the myRIO for a sous vide cooking apparatus similiar to this: https://learn.adafruit.com/sous-vide-powered-by-arduino-the-sous-viduino/sous-vide. I will be using a slow-cooker as the heating element; for the temperature measurements, I am using the DS18B20 one-wire temperature sensor; and to alter the temperature I am using a relay connected to the slow cooker.
    I have had success getting temperature measurements from the DS18B20 with the myRIO following the guidance of this thread: https://decibel.ni.com/content/docs/DOC-41626#comment-44403, however, I am having difficulty finding a starting place to learn how to use the PID VIs for the rest of the project. In a new VI file, I used the program I had used for the temperature readings as a subVI, and tried to connect its output containing the live numerical temperature measurements into the PID VI, but the live temperature measurements as well as the PID VI output are not being transmitted after running the program.
    Here are a few more specific questions:
    Are there any preliminary steps for creating a PID program to accept live measurements from a myRIO target (should the program be enclosed in a loop for continuous updating of myRIO measurements)?
    What information is transmitted at the "output" terminal of the PID VI?
    Is autotuning recommended for this type of application?
    How does the "PID Autotuning" VI differ from the "PID Autotuning (Temperature)" VI?
    I have attached the files I am currently working with: ("1-wire interface.lvproj" is the project file, "RT Main.vi" is the temperature reading program, "PID_Test" is the new PID VI file I am experimenting with).
    If the content in this post is not appropriate to what is expected to be asked in the forums (not specific enough, etc.), please let me know and I apologize in advance. Thank you for your time and assistance!

    Hello dpull,
    There shouldn’t be any particular configuration that needs to be done, for the PID vi to start using the PID VIs, and if you desire to continously acquire the data from the myRIO, then this within a loop might be appropriate.
    The output terminal transmits the control signal of the PID controller, so basically the action that would have to take place to take the desired value to the setpoint.
    As far as recommending autotuning, it mostly  depends on your application and the precision you need, it would always be better to determine the parameters yourself, but if you don’t require super high accuracy, then autotunning should be sufficient.
    The PID autotunning (Temperature) VI is used for processes that include a dead time, since it’s incorporated into that model, the other one is better suited for processes that don’t have dead time.
    As far as resources go for learning to use this toolkit, I’d recommend sticking to the examples you can find in LabVIEW and maybe the following manual.
    http://www.ni.com/pdf/manuals/372192d.pdf

  • Program structure for a report

    hi,
    could any one clarify whether
    initialization event is to be  written first or
    selection-screen begin of block is to be written.plz tell whether this affects performance.
    I have written a report with the following structure.plz correct me if i'm wrong
    1)DB table declaration
    2) internal tables declaration and ranges decltn
    3)ALV variables & internal tables
    4)constants & variables
    5)initialization
    6)selection-screen(begin of block-end of block)
    7)at selection-screen on value req
    8) at selection-screen
    9)start-of-selection
    10)end-of-selection

    Hi Mamatha
    There is absolutely no need of worrying about which should come first and which next...
    Anything is fine...whether INITIALIZATION coming first or vice-versa. and further, there is no connection of this with performance. Infact, let me tell you that PERFORMANCE comes into picture only when u r accessing the database or when u r processing large internal tables.
    <b>and regarding the order of ur report:</b>
    Its fine! How ever, for more readability, u can swap the 5th and 6th steps, so that all the events are grouped at one place and all the data declarations above them.
    And let me tell u one important thing: Don't allow the data declaration to happen in SELECTION-SCREEN events, it will not be global.....
    Hope u understand me completely
    Reward points if helpful
    Regards

  • What's the best program structure for multi-channel Averaged FFTs?

    I have been successfully using a 8-channel FFT analyzer using a separate Averaged FFT Spectrum (Mag-Phase) VI for each channel, but I now need to expand my channel count from 8 to 16. All channels are simultaneoulsy read in to a buffer to maintain phase relatioships. Do I need to have 16 copies of the Averaged FFT Spectrum VI in my diagram to maintain the averages of each channel or can I utilize one FFT VI somehow within a For Loop? If a For Loop can be used, how can the averaged spectrums be maintained for each of the 16 channels?

    You should be able to use a single FFT vi in a for loop. If your data is in a 2D array representation with each row representing a channel and you leave the indexing enabled you can pass your data array into the loop and it will strip off each row automatically. You could then pass each row of data to the FFT and pass the results out to the boundary of the for loop. This will then build an array containing the FFT results for each row (channel).
    Marc
    Marc

  • DLTS System (Trio-tech TC 1000 Temperature controller)

    Hi I was trying to make DLTS(Deep Level Transient Spectroscopy) system using Agilent 4284A LCR Meter and Trio-tech TC1000 Temperature controller.
    I'm done with LCR Meter but I don't know how to start Temperature controller.
    There was labview driver for LCR Meter so I just modified exiting VI.
    However there is no example for controlling Temperature controller by Labview.
    Please help me if you can.
    Thanks for reading this
    Message Edited by daniel2852 on 02-13-2006 07:44 PM

    Hi Daniel,
    If you know the command set of your instrument, you can try communication using the VISA API.  You probably have NI-VISA installed already since it is required for most of the instrument drivers on our web page.  If you do not have it, you will need to download it from here.  Is your temperature controller a GPIB Instrument?  If so, try using the example I have attached below that uses the basic VISA functionality to write a command to the instrument and read back the response.  You will need LabVIEW 7.0 or higher to run it.  Just put in your gpib device resource name and a known command into the VISA Write and set it to read an expected number of bytes.  You should be able to read command responses directly from the instrument.  If this works, you can try to build your own driver around this example.  You can also try using the Instrument I/O Assistant Express VI which often allows for instrument communication without instrument drivers.  This can be found on the Express palette on the block diagram in LabVIEW.  I also suggest going to www.ni.com/idnet and selecting "Request Instrument Drivers" to put in a request to our driver development team.  These are considered when developing new drivers for future releases. 
    I hope this works for you, but if you have any questions, please let me know!
    Chris R.
    Applications Engineer
    National Instruments
    Chris R.
    Applications Engineer
    National Instruments
    Attachments:
    Basic GPIB Write and Read LV70.vi ‏26 KB

  • Temperature controller

    I am new to labview and I am trying to create a temperature controller. I looked over the PID temperature controller example and have most of my VI working. What I would like to do ideally is have a user input a set of arbitrary times and temperatures via a two column table. This set of data would them be interpolated and a graph created just like the simulate arbitrary signal VI does. After this data is loaded by a push button on my VI by some push button on my VI, the VI would compare the measured signal to the desired signal input by the user. If the measured temperature was less than the desired signal a boolean 1 would be output, which would turn on a heater. My two main problems are setting up a table on the front panel of my VI to accept and create the desired "temperature curve", and graphing the actual temperature on the same graph as the desired temperature(s). Currently I have the desired temperature being input in the Simulate Arbitrary Signal VI's properties, and it compares and outputs properly to the heaters. Everything works fine, but I would like to graph both data sets on the same graph. My actual measurements are single 32-bits, while my desired signal is a dynamic data set. Any help would be appreciated
    Thanks-
    Bill

    JRA i am posting my VI as you suggested me on 4/7/2003
    Attachments:
    HITACHI_F-2000_TEMPERATURE_CONTROLLER.vi ‏110 KB

  • I need an instrument driver for Neocera LTC-21 Temperature Controller and am having problems sending the IDN? string to the same instrument.

    Hi,
    When I use the instrument wizard in LabVIEW 5.0, to indentify a device (Neocera LTC-21 Temperature Controller), I receieve the following error:
    Error.
    There was an error sending this string.
    VISA error code returned was:
    -1073807339
    Error -1073807339 occured at VISA Read.
    Possible reasons:
    VISA: (Hex 0xBFFF0015) Timeout expired before operation completed.
    Although, the manual for this instrument states that the response should be a string of characters in the form of "Neocera Model LTC-21 version".
    Also, I do not have a driver for this instrument, inspite of checking on the NI Instrument
    Divers Network and the company website(www.Neocera.com).
    I would truely appreciate if someone can help me.
    Thanks,
    Kunal.

    I could not find any drivers for that instrument. You may just have to make your own. As for getting the device to respond, there are a couple of things you can do. If you are using GPIB: First, you might want to just reset the device by turning it on and off. If there are other instruments on the same bus, make sure 2/3 of them have their power on. Try communicating with it through IBIC. Here is a page that will help.
    http://www.ni.com/support/gpib/max/ibic.htm
    IBIC communicates with the GPIB on a very base driver level and you set everything manually step by step, so you can see where the break down is. Also make sure you are entering the "*IDN?" and all other commands correctly. Check the device manual to see what commands it should respond to and if there ar
    e any special settings you might need. If you are doing serial communication, you may want to check to see if you need a null modem cable for it to function. There also may be a dip switch on the device that switches between serial and GPIB communication.

  • Chromalox 6040 and 6050 temperature controller with RS485

    Hi,
     I have a Chromalox heater and the Tempererature controllers (6040 and 6050).  Both controllers has the RS485 hook-up.  I would like to know how to communicate with these devices.  The devices themselves can function as an stand alone units with PID controller installed. These devices can be used with automatic or manual control.  I would like to set it on automatic and control it from Labview.  I am currenlty using the Fieldpoints modules with Labview 2009. I have several questions: 1. can I wire the RS485 2-wire connector directly to the field point module?  2.  if I need an RS 485 converter, I will use the RS485 to USB.  Would I then just use the RS232 visa? 3.  there are two connection on the controller for the RS485, I am not sure how to wire that together as twisted wire.  I have looked at the forum on the subjects and find bits and pieces of info..  I would like more directions.
    Thank you,

    Sorry, I believe I convoluted the issue here at hand.  Let me retract my earlier statement and say this.  Your FieldPoint module has the RS232 port on it, where you can write serial commands out to the device (I mentioned using Optomux earlier, while this is possible, upon second thought it is unnecessary).  You can then have the RS485 port write out to your temperature controllers.  Is this what you are trying to accomplish?  You should be able to wire the connections directly to the FieldPoint module.  Sorry for convoluting the issue earlier.  Does this answer your question more closely?  You mentioned using an RS485 to USB converter, where does that come into play?  I understood that you wanted to go from the FieldPoint RS485 port to an RS485 port onthe temperature controller?
    Regards,
    Shane C
    Applications Engineer
    National Instruments

  • Question about program structure.

    hi, I am trying to write a GUI program like MSN messenger. right now, I am really confused about my program structure.
    Should I put all the things in one class or separate them into GUI class, services class..etc? for example, right now, I have a class responsible for connecting to the server. Should I put it into the GUI class as a nested class or .......? Basically, what is the best structure for GUI program?

    new_java-sun wrote:
    thank you very much. Do you know why the mvc pattern is called mvc pattern instead of DGC(data-gui-controller) pattern?Because a view need not be a GUI, or even a UI, and a model need not be data

  • NI Serial Port / Eurotherm Temperature Controller

    NI Serial Port / Eurotherm Temperature Controller
    I am using a N.I. AT 232/4 board with four additional N.I. serial ports. First of all, after installing Windows NT (before I was using Windows 98) the NI Serial Port Diagnostics Program was not able to detect any of the ports even though the ports are correctly installed within Windows. When I was still using Windows 98 the NI Serial Port Diagnostics Program was able to detect all the four ports. Is it necessary that the diagnostics program detects the ports in order to use them with Lab View? I have also two regular Serial ports, which have never been detected by the diagnostics program, but I should still be able to use them with Lab view as well? D
    oes the NI Serial Port Diagnostics Program not function with Windows NT? Do you have an update version for Windows NT?
    I�m trying to control a Eurotherm 2416 and 903 Temperature Controller with two serial ports. Unfortunately, Eurotherm does not give support anymore about Lab View drivers for their Controllers, since they have developed their own Automation Program (iTools) now. I still want to control the Eurotherm Controller with Lab View via the serial port. Do you still have the driver VI�s for the 2416 and 903? It would be nice if you could send me the Eurotherm divers also along with some documentation.
    There is already a question posted about Eurotherm Controller (Eurotherm Temperature Controller not Functioning with NI Serial Board). It is probably a similar problem unfortunately the solution did not bring the right success. Therefore, I would like to ask you to specify the so-called 4-Wire mode.
    Thank You very much for Your help!
    Sincerely,
    Benjamin Thoma

    NI-Serial 1.45 does not install correctly on Windows NT Server 4.0 Terminal Server Edition. The driver (serial.sys), configuration utility (niports.cpl), and inf file (niserial.inf) are installed incorrectly to the user profiles directory.
    A workaround is to copy the files to the right folders which is detailed shortly.
    Definition: "%windows%" refers to the operating system folder. Note: The default operating system folder for this version of Windows is "Wtsrv".
    serial.sys - %windows%\system32\drivers
    niports.cpl - %windows%\system32
    niserial.inf - %windows%\inf
    Note: "niserial.inf" does not need to be copied unless an AT card is being used.
    The above files can either be obtained from the installation CD in the WinNT folder or from the hard-disk locations that they were
    incorrectly installed to which are detailed shortly. Note: Leaving the incorrectly installed files where they are will not harm the system. Definition: "%userid%" refers to the ID that was used when logging in to Windows.
    serial.sys - %windows%\Profiles\%userid%\Windows\system32\drivers
    niports.cpl - %windows%\Profiles\%userid%\Windows\system32
    niserial.inf - %windows%\Profiles\%userid%\Windows\inf
    For the newly copied driver to take effect the system must be rebooted.
    As for the instrument drivers, you can search our instrument driver site to try to find them. Go to "other driver resources" at the link below.
    http://zone.ni.com/idnet/
    For more information on the 4-wire mode, see chapter 6 of the "Serial Hardware and Software for Windows User Manual". I have included a link to the manual.
    http://digital.ni.com/manuals.nsf/caba5d53e9b015a186256793004eebb7/d1260d4fb98e3f228625699f005968d1?OpenDocument
    Kim L.
    Applications Engineer
    National Instruments

  • Help with program structure - simple question.

    Hi. I need a piece of advice on how to create the correct structure for my program. It consist on two main processes:
    1)Detecting time difference between 2 rising edges, and showing the data. I used the concept of another user "panoramarts" that you can see here:
    http://forums.ni.com/t5/Digital-I-O/Measuring-Time​-between-two-Digital-Signals/m-p/2091868#M16230
    (If anyone knows a better way to do it I will really appreciate it)
    2) A continuous process.
    I attached a picture of the structure I am using. The numbers I will refer to, are indicated there.
    The program basically starts counting the time until a rising edge is detected (number 2 in the picture). After that the next sequence is executed (number 3 in the picture) counting the time again until the next edge is detected. After that the subtraction is made to have the time difference and then displayed (number 4 in the picture).
    Here is the problem: I have a continuous process that must be executed, so if I place it in "Number 1" then the edge detection must be running otherwise i do not see the continuous process (is like Labview execute de FLAT sequence, and after that the continuous process). If a place the continuous process in another While loop, then is like sometimes I get inaccurate data from the edge detection.
    How can I solve that? Is there another way to acquire time between edges? I hope you can help me without the VI.
    I am using Arduino, so I can not use DAQmx VI's.
    DMDsync
    Attachments:
    program structure.jpg ‏54 KB

    Thanks for the quick feedback!
    I believe my problem is that I am not using the best way to estimate time between edges. As I previously said, I am using almost the exact VI that "Panoramarts" shared in this link:
    http://forums.ni.com/t5/Digital-I-O/Measuring-Time​-between-two-Digital-Signals/m-p/2091868#M16230
    The only difference is that instead of a DAQ assistant in each of the While Loops, I use the same input for both of them. It works ok. It measure the time difference between the 1st and 2nd edges, the 3rd and 4th, and so on. All that VI is inside a while loop to continuously perform the counting. May be I can simplify my question:
    How can I continuously measure time difference between incoming edges (it could be a Boolean variable varying from true to false periodically) in a VI that already has a continuous process running?
    As Altenbach said, I used a wait statement in the continuous process (as it is not necessary a fast data update for it, because it is just a simple temperature measurement), but that delay created some faulty timing in the edge timing sequence.
    Any ideas?
    Thanks again!
    DMDsync

  • Performing temperature sweep with lakeshore 340 temperature controller

    I am working on a design project to run a temperature sweep using a lakeshore 340 temperature controller. I need it to increase in steps, wait for the temperature to stabilize and then ramp up to the next setpoint. I need to be able to repeat this process a finite amount of times. I believe I could check if it is stabilized using Booleans and a sequence structure, but I don't know anything about changing the setpoint automatically if anyone could help at all that would be really great. Thanks. 

    The instructions for how to set the temperature should be available at their website. I do not know what commands it uses since it is not an NI product.
    Kyle K.
    Product Manager for Product Data
    National Instruments

  • SD Flow program using For all entries.

    using simple ALV grid: I have the urgent requirement of changing the following program using 'For all entries' instead of joins and I should not use 'TABLES' -- For top-of-page I need to get dynamic fields like if I select company code in the selection screen then I need to get 'This report is base on COMPANY CODE'.
    This program is about sales flow where i shud get only those records that have ebeln in vbak, delivery, invoice.
    The original program is as follows:
    *& Report  ZSD_DOCU_FLOW                                               *
    REPORT  zsd_docu_flow  NO STANDARD PAGE HEADING                    .
    * Program     : ZCOS_SALES                                           *
    * Dev. Class  :  ZSD
    * Functional  :
    * Created on  :                                                        *
    * Project     :
    * CR Number   :
    * Transaction :  ZSDCSUT                                               *
    * Description :   * Sales document life cylce for given customer
    *                  to declaired period displaying the sales document
    *                  details ,with relevant del details and corresponding
    *                  Invocie Details
    *-----------     Tables Declaration      -----------*
    TABLES: vbak,vbap,vbfa,kna1,vbrk,vbrp,likp,lips,t001.
    TYPE-POOLS : slis.
    *-----------    Internal Tables Declaration      -----------*
    *      Internal Table for Sales Order data                   *
    DATA: BEGIN OF it_so OCCURS 0,
            vbeln LIKE vbak-vbeln,
            kunnr LIKE vbak-kunnr,
            posnr LIKE vbap-posnr,
            matnr LIKE vbap-matnr,
            kwmeng LIKE vbap-kwmeng,
            netwr LIKE vbap-netwr,
         END OF it_so.
    *      Internal Table for Delivery Order data                   *
    DATA: BEGIN OF it_del OCCURS 0,
            delnum  LIKE likp-vbeln,
            lfdat LIKE likp-lfdat,
            delitem LIKE lips-posnr,
            lfimg LIKE lips-lfimg,
          END OF it_del.
    *      Internal Table for Invoice data                          *
    DATA: BEGIN OF  it_inv OCCURS 0,
            invnum LIKE vbrk-vbeln,
            invitem LIKE vbrp-posnr,
            fkimg LIKE vbrp-fkimg,
            amount LIKE vbrp-netwr,
         END OF it_inv.
    *      Internal Table for Final data                            *
    DATA: BEGIN OF it_final OCCURS 0,
            vbeln LIKE vbak-vbeln,
            posnr LIKE vbap-posnr,
            kunnr LIKE vbak-kunnr,
            name LIKE kna1-name1,
            matnr LIKE vbap-matnr,
            kwmeng LIKE vbap-kwmeng,
            netwr LIKE vbap-netwr,
            delnum  LIKE likp-vbeln,
            lfdat LIKE likp-lfdat,
            delitem LIKE lips-posnr,
            lfimg LIKE lips-lfimg,
            invnum LIKE vbrk-vbeln,
            invitem LIKE vbrp-posnr,
            fkimg LIKE vbrp-fkimg,
            amount LIKE vbrp-netwr,
         END OF it_final.
    *-----------    Variables Declaration      -----------*
    DATA: v_name LIKE kna1-kunnr," variable for customer name
          v_delnum LIKE likp-vbeln," variable for delivery number
          v_invnum LIKE vbrk-vbeln." variable for invoce number
    DATA : ls_layout TYPE slis_layout_alv,
           it_fcat TYPE slis_t_fieldcat_alv ,
           wa_fcat TYPE slis_fieldcat_alv,
           lh TYPE slis_t_listheader,
           ls TYPE slis_listheader,
           it_events TYPE slis_t_event  ,
           ls_event TYPE slis_alv_event ,
           i_sort     TYPE slis_t_sortinfo_alv,
           w_var TYPE i.
    DATA : l_date(10).
    DATA : l_date1(20).
    DATA : l_repid LIKE trdir-name.
    l_repid = 'ZSD_DOCU_FLOW1'.
    *-----------    Select-options & parameters Declaration  ---*
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: p_bukrs LIKE vbak-bukrs_vf,
                 p_vkorg LIKE vbak-vkorg,
                p_vtweg LIKE vbak-vtweg,
                p_spart LIKE vbak-spart.
    SELECT-OPTIONS: s_kunnr FOR vbak-kunnr,
                    s_audat FOR vbak-audat.
    SELECTION-SCREEN END OF BLOCK b1.
    *----------- AT SELECTION-SCREEN  --------------------------*
    AT SELECTION-SCREEN.
      SELECT SINGLE * FROM  t001 INTO t001
                                WHERE bukrs = p_bukrs.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Company Code'.
      ENDIF.
      SELECT SINGLE * FROM vbak INTO vbak
                              WHERE vkorg = p_vkorg.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Sales Organization'.
      ENDIF.
      SELECT SINGLE * FROM vbak INTO vbak
                                WHERE vtweg = p_vtweg.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid distribution channel'.
      ENDIF.
      SELECT SINGLE * FROM vbak INTO vbak
                                WHERE spart = p_spart.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Division'.
      ENDIF.
      SELECT SINGLE * FROM kna1 INTO kna1
                                WHERE kunnr IN s_kunnr.
      IF sy-subrc <> 0.
        MESSAGE e000(8i) WITH 'Enter a Valid Customer Number'.
      ENDIF.
    *----------- START-OF-SELECTION-----------------------------*
    START-OF-SELECTION.
      ls-typ = 'H'.
      ls-info = 'Sales Document Flow'.
      APPEND ls TO lh.
      ls-typ = 'S'.
      WRITE: sy-datum TO l_date USING EDIT MASK '__/__/____'.
      CONCATENATE 'DATE :' l_date INTO l_date1 SEPARATED BY space.
      ls-info = l_date1.
      APPEND ls TO lh.
      PERFORM field_cat.
      PERFORM t_sort_build USING i_sort.
      PERFORM get-data.
    *----------- END-OF-SELECTION-----------------------------*
    END-OF-SELECTION.
    IF it_final[] IS INITIAL.
        MESSAGE i000(8i) WITH 'No data Found'.
        EXIT.
      ENDIF.
    PERFORM print-data.
    *&      Form  get-data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get-data .
    *  Accesing Sales Data
      SELECT a~vbeln a~kunnr b~posnr b~matnr b~kwmeng b~netwr
       INTO CORRESPONDING FIELDS OF TABLE it_so
       FROM vbak AS a INNER JOIN vbap AS b
                             ON a~vbeln = b~vbeln
                              WHERE a~bukrs_vf = p_bukrs
                                 AND a~vkorg = p_vkorg
                                 AND  a~vtweg = p_vtweg
                                    AND a~spart = p_spart
                                     AND a~kunnr IN s_kunnr
                                          AND a~audat IN s_audat.
      LOOP AT it_so.
        SELECT SINGLE name1 FROM kna1 INTO v_name
                                         WHERE kunnr = it_so-kunnr.
        SELECT SINGLE vbeln FROM vbfa INTO v_delnum
                                          WHERE vbelv = it_so-vbeln
                                            AND  vbtyp_n = 'J'.
        IF sy-subrc = 0.
          SELECT SINGLE  vbeln FROM vbfa INTO v_invnum
                                WHERE vbelv = v_delnum
                                  AND  vbtyp_n = 'M'.
        ENDIF.
        MOVE-CORRESPONDING it_so TO it_final.
        it_final-name = v_name.
        it_final-delnum = v_delnum.
        it_final-invnum = v_invnum.
        APPEND it_final.
        CLEAR it_final.
        CLEAR v_delnum.
        CLEAR v_invnum.
      ENDLOOP.
      LOOP AT it_final.
        IF it_final-delnum NE ' '.
    * Reading Del Data.
          SELECT SINGLE  a~vbeln  a~lfdat b~posnr b~lfimg   INTO
                    (it_del-delnum, it_del-lfdat, it_del-delitem,
                     it_del-lfimg ) FROM
                        likp AS a INNER JOIN lips AS b ON a~vbeln = b~vbeln
                                   WHERE a~vbeln = it_final-delnum
                                   AND b~posnr = it_final-posnr.
          MOVE-CORRESPONDING it_del TO it_final.
          MODIFY it_final.
        ENDIF.
        IF it_final-invnum NE ' '.
    * Reading Invoice Data.
          SELECT SINGLE vbeln posnr fkimg netwr INTO
         (it_inv-invnum, it_inv-invitem, it_inv-fkimg, it_inv-amount )
                       FROM vbrp  WHERE vbeln = it_final-invnum
                                  AND   posnr = it_final-posnr.
          MOVE-CORRESPONDING it_inv TO it_final.
          MODIFY it_final.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " get-data
    *&      Form  print-data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM print-data .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
    *     I_INTERFACE_CHECK                 = ' '
    *     I_BYPASSING_BUFFER                = ' '
    *     I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = l_repid
    *     I_CALLBACK_PF_STATUS_SET          = ' '
    *     I_CALLBACK_USER_COMMAND           = ' '
         i_callback_top_of_page            = 'TOP'
    *     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *     I_CALLBACK_HTML_END_OF_LIST       = ' '
    *     I_STRUCTURE_NAME                  =
    *     I_BACKGROUND_ID                   = ' '
    *     I_GRID_TITLE                      =
    *     I_GRID_SETTINGS                   =
    *     IS_LAYOUT                         =
         it_fieldcat                       = it_fcat
    *     IT_EXCLUDING                      =
    *     IT_SPECIAL_GROUPS                 =
         IT_SORT                           = i_sort[]
    *     IT_FILTER                         =
    *     IS_SEL_HIDE                       =
    *     I_DEFAULT                         = 'X'
    *     I_SAVE                            = ' '
    *     IS_VARIANT                        =
    *     IT_EVENTS                         =
    *     IT_EVENT_EXIT                     =
    *     IS_PRINT                          =
    *     IS_REPREP_ID                      =
    *     I_SCREEN_START_COLUMN             = 0
    *     I_SCREEN_START_LINE               = 0
    *     I_SCREEN_END_COLUMN               = 0
    *     I_SCREEN_END_LINE                 = 0
    *     IT_ALV_GRAPHICS                   =
    *     IT_HYPERLINK                      =
    *     IT_ADD_FIELDCAT                   =
    *     IT_EXCEPT_QINFO                   =
    *     I_HTML_HEIGHT_TOP                 =
    *     I_HTML_HEIGHT_END                 =
    *   IMPORTING
    *     E_EXIT_CAUSED_BY_CALLER           =
    *     ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = it_final.
    *   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.                    " print-data
    *&      Form  field_cat
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM field_cat .
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'VBELN'.
      wa_fcat-key = 'X'.
      wa_fcat-ref_fieldname = 'VBELN'.
      wa_fcat-ref_tabname = 'VBAK'.
      wa_fcat-seltext_m = 'Sales Order NO'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'POSNR'.
      wa_fcat-ref_fieldname = 'POSNR'.
      wa_fcat-ref_tabname = 'VBAP'.
      wa_fcat-seltext_m = 'SalesItemNO'.
      wa_fcat-fix_column = 'X'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'KUNNR'.
      wa_fcat-seltext_m = 'CUSTNUM'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'NAME'.
      wa_fcat-seltext_m = 'CUSTNAME'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-seltext_m = 'MATNUM'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'KWMENG'.
      wa_fcat-seltext_m = 'Sales Quantity'.
      wa_fcat-do_sum = 'X'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'NETWR'.
      wa_fcat-seltext_m = 'Value'.
      wa_fcat-do_sum = 'X'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'DELNUM'.
      wa_fcat-seltext_m = 'DeloveryNum'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'DELITEM'.
      wa_fcat-seltext_m = 'DelItemNO'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'LFDAT'.
      wa_fcat-seltext_m = 'DelDate'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'LFIMG'.
      wa_fcat-seltext_m = 'DelQuantity'.
      wa_fcat-do_sum = 'X'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'INVNUM'.
      wa_fcat-seltext_m = 'InvoiceNum'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'INVITEM'.
      wa_fcat-seltext_m = 'InvoiceItem'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'FKIMG'.
      wa_fcat-seltext_m = 'INVQuantity'.
      wa_fcat-do_sum = 'X'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
      wa_fcat-col_pos = w_var.
      wa_fcat-tabname = 'IT_FINAL'.
      wa_fcat-fieldname = 'AMOUNT'.
      wa_fcat-seltext_m = 'INVvalue'.
      wa_fcat-do_sum = 'X'.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
      ADD 1 TO w_var.
    ENDFORM.     " field_cat
    *&      Form  top
    *       text
    FORM t_sort_build USING l_sort TYPE slis_t_sortinfo_alv.
      DATA: ls_sort TYPE slis_sortinfo_alv.
      ls_sort-fieldname = 'VBELN'.
      ls_sort-spos      = 1.
      ls_sort-up        = 'X'.
      ls_sort-subtot    = 'X'.
      APPEND ls_sort TO l_sort.
      ls_sort-fieldname = 'KUNNR'.
      ls_sort-spos      = 2.
      ls_sort-up        = 'X'.
      APPEND ls_sort TO l_sort.
    ENDFORM.                    "t_sort_bui
    FORM top.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = lh
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    ENDFORM.                    "TOP
    ===========================================================================
    I have started the new program but i have trouble with the final internal table. Since i'm using For all entries I have declared internal tables for each table. My incomplete new program is as follows(not sure if the logic is correct till what I have coded):
    *& Report  Z_SDFLOW                                                    *
    REPORT  Z_SDFLOW  NO STANDARD PAGE HEADING.
    ********* TABLES TO BE USED ***********************
    **** VBAK - SALES DOCUMENT HEADER
    * VBAP - SALES ITEM
    * VBFA - SALES DOCUMENT FLOW
    * KNA1- CUSTOMER MASTER
    * VBRK - BILLING DOCUMENT HEADER
    * VBRP - BLLING DOCUMENT ITEM
    * LIKP - DELIVERY HEADER
    * LIPS - DELIVERY ITEM
    * TOO1 - COMPANY CODES
    * SLIS.
    TYPE-POOLS: SLIS.
    ** STRUCTURE DECLARATIONS ********
    **STRUCTURE FOR ENQUIRY.
    **STRUCTURE FOR QUOTATION.
    **STRUCTURE FOR SALES ORDER HEADER- VBAK.
    TYPES: BEGIN OF XT_VBAK,
    VBELN TYPE VBAK-VBELN,     "SALES DOCUMENT NUMBER
    KUNNR TYPE VBAK-KUNNR,     " SOLD-TO-PARTY
    END OF XT_VBAK.
    **STRUCTURE FOR SALES ORDER  ITEM-VBAP
    TYPES: BEGIN OF XT_VBAP,
    POSNR TYPE VBAP-POSNR,     " SALES ITEM NUMBER
    MATNR TYPE VBAP-MATNR,     " MATERIAL NUMBER
    KWMENG TYPE VBAP-KWMENG,   " CUMMULATIVE ORDER QUANTITY IN SALES UNITS
    NETWR TYPE VBAP-NETWR,     " NET VALUE OF THE ORDER ITEM
    END OF XT_VBAP.
    ** STRUCTURE FOR DELIVERY HEADER -LIKP
    TYPES: BEGIN OF XT_LIKP,
    DELVBELN TYPE LIKP-VBELN,           "DELIVERY DOCUMENT NUMBER
    LFDAT TYPE LIKP-LFDAT,           " DELIVERY DATE
    END OF XT_LIKP.
    **STRUCTURE FOR DELIVERY ITEM - LIPS
    TYPES: BEGIN OF XT_LIPS,
    DELPOSNR TYPE LIPS-POSNR,           " DELIVERY ITEM NUMBER
    LFIMG TYPE LIPS-LFIMG,           " ACTUAL QUANTITY DELIVERED
    END OF XT_LIPS.
    **STRUCTURE FOR BILLING DOCUMENT HEADER -VBRK
    TYPES: BEGIN OF XT_VBRK,
    INVVBELN TYPE VBRK-VBELN,          "BILLING DOCUMENT NUMBER
    END OF XT_VBRK.
    **STRUCTURE FOR BILLING DOCUMENT ITEM - VBRP
    TYPES: BEGIN OF XT_VBRP,
    INVPOSNR TYPE VBRP-POSNR,          "BILLING ITEM NUMBER
    FKIMG TYPE VBRP-FKIMG,          "ACTUAL INVOICED QUANTITY
    INVNETWR TYPE VBRP-NETWR,          "NET VALUE OF THE BILLING ITEM
    END OF XT_VBRP.
    **STRUCTURE FOR FINAL INTERNAL TABLE.
    TYPES: BEGIN OF XT_FINAL,
    VBELN TYPE VBAK-VBELN,
    DELVBELN TYPE LIKP-VBELN,
    INVBELN TYPE VBRK-VBELN,
    KUNNR TYPE VBAK-KUNNR,
    POSNR TYPE VBAP-POSNR,
    DELPOSNT TYPE LIPS-POSNR,
    INVPOSNR TYPE VBRP-POSNR,
    MATNR TYPE VBAP-MATNR,
    KWMENG TYPE VBAP-KWMENG,
    NETWR TYPE VBAP-NETWR,
    INVNETWR TYPE VBRP-NETWR,
    LFDAT TYPE LIKP-LFDAT,
    LFIMG TYPE LIPS-LFIMG,
    FKIMG TYPE VBRP-FKIMG,
    NAME1 TYPE KNA1-NAME1,
    END OF XT_FINAL.
    **DATA DECLARATIONS
    DATA: V_NAME1 TYPE KNA1-NAME1,  "#EC *
          V_DELVBELN TYPE LIKP-VBELN,
          V_INVVBELN TYPE VBRK-VBELN,
          V_BUKRS TYPE T001-BUKRS,    "COMPANY CODE "#EC *
          V_AUDAT TYPE VBAK-AUDAT,
          V_VKORG TYPE VBAK-VKORG,
          V_VKGRP TYPE VBAK-VKGRP,
          V_SPART TYPE VBAK-SPART.
    **INTERNAL TABLE DECLARATIONS
    DATA: IT_VBAK TYPE STANDARD TABLE OF XT_VBAK,
          WA_VBAK TYPE XT_VBAK,
          IT_VBAP TYPE STANDARD TABLE OF XT_VBAP,
          WA_VBAP TYPE XT_VBAP,
          IT_LIKP TYPE STANDARD TABLE OF XT_LIKP,
          WA_LIKP TYPE XT_LIKP,
          IT_LIPS TYPE STANDARD TABLE OF XT_LIPS,
          WA_LIPS TYPE XT_LIPS,
          IT_VBRK TYPE STANDARD TABLE OF XT_VBRK,
          WA_VBRK TYPE XT_VBRK,
          IT_VBRP TYPE STANDARD TABLE OF XT_VBRP,
          WA_VBRP TYPE XT_VBRP,
          IT_FINAL TYPE STANDARD TABLE OF XT_FINAL,
          WA_FINAL TYPE XT_FINAL.
    **ALV DECLARATIONS
    DATA: IT_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,
          WA_FLDCAT TYPE SLIS_FIELDCAT_ALV,
          IT_LSTHDR TYPE SLIS_T_LISTHEADER,
          WA_LSTHDR TYPE SLIS_LISTHEADER,
          IT_EVENTS TYPE SLIS_T_EVENT,
          WA_EVENTS TYPE SLIS_ALV_EVENT,
          IT_SORT TYPE SLIS_T_SORTINFO_ALV,
          IT_LAYOUT TYPE SLIS_LAYOUT_ALV.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: S_BUKRS FOR V_BUKRS NO INTERVALS NO-EXTENSION,
                    S_VBELN FOR WA_VBAK-VBELN,  "SALES DOCUMENT NUMBER
                    S_KUNNR FOR WA_VBAK-KUNNR,  "SOLD-TO-PARTY
                    S_AUDAT FOR V_AUDAT,      "SALES DOCUMENT DATE
                    S_VKORG FOR V_VKORG,      "SALES ORGANISATION
                    S_VKGRP FOR V_VKGRP,      "SALES GROUP
                    S_SPART FOR V_SPART.      "DIVISION
    SELECTION-SCREEN END OF BLOCK b1.
    *****************SCREEN VALIDATION***************
    AT SELECTION-SCREEN.
    SELECT SINGLE BUKRS FROM T001 INTO V_BUKRS WHERE BUKRS IN S_BUKRS."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID COMPANY CODE'.
    ENDIF.
    SELECT SINGLE VBELN FROM VBAK INTO
              CORRESPONDING FIELDS OF WA_VBAK WHERE VBELN IN S_VBELN.
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER VALID SALES DOCUMENT NUMBER'.
    ENDIF.
    SELECT SINGLE KUNNR FROM VBAK INTO
              CORRESPONDING FIELDS OF WA_VBAK WHERE KUNNR IN S_KUNNR. "EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID CUSTOMER NUMBER'.
    ENDIF.
    SELECT SINGLE AUDAT FROM VBAK INTO V_AUDAT WHERE AUDAT IN S_AUDAT."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES DOCUMENT DATE'.
    ENDIF.
    SELECT SINGLE VKORG FROM VBAK INTO V_VKORG WHERE VKORG IN S_VKORG."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES ORGANISATION'.
    ENDIF.
    SELECT SINGLE VKGRP FROM VBAK INTO V_VKGRP WHERE VKGRP IN S_VKGRP."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES GROUP'.
    ENDIF.
    SELECT SINGLE SPART FROM VBAK INTO V_SPART WHERE SPART IN S_SPART."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES DIVISION'.
    ENDIF.
    PERFORM GET_DATA.
    *&      Form  GET_DATA
    FORM GET_DATA .
    SELECT VBELN KUNNR
            INTO TABLE IT_VBAK
            FROM VBAK
            WHERE VBELN IN S_VBELN.
    *        BUKRS_VF IN S_BUKRS AND
    *        VKORG IN S_VKORG AND
    *        VKGRP IN S_VKGRP AND
    *        SPART IN S_SPART AND
    *        KUNNR IN S_KUNNR AND
    *        AUDAT IN S_AUDAT.
    IF IT_VBAK[] IS NOT INITIAL.
    SELECT POSNR MATNR KWMENG NETWR
            INTO TABLE IT_VBAP
            FROM VBAP
            FOR ALL ENTRIES IN IT_VBAK
            WHERE VBELN = IT_VBAK-VBELN.
    ENDIF.
    IF IT_VBAK[] IS NOT INITIAL.
    SELECT VBELN LFDAT
            INTO TABLE IT_LIKP
            FROM LIKP
            FOR ALL ENTRIES IN IT_VBAK
            WHERE VBELN = IT_VBAK-VBELN.
    ENDIF.
    IF IT_VBAP[] IS NOT INITIAL.
    SELECT POSNR LFIMG
            INTO TABLE IT_LIPS
            FROM LIPS
            FOR ALL ENTRIES IN IT_VBAP
            WHERE POSNR = IT_VBAP-POSNR.
    ENDIF.
    IF IT_LIKP[] IS NOT INITIAL.
    SELECT VBELN
            INTO TABLE IT_VBRK
            FROM VBRK
            FOR ALL ENTRIES IN IT_LIKP
            WHERE VBELN = IT_LIKP-DELVBELN.
    ENDIF.
    IF IT_LIPS[] IS NOT INITIAL.
    SELECT POSNR FKIMG NETWR
            INTO TABLE IT_VBRP
            FROM VBRP
            FOR ALL ENTRIES IN IT_LIPS
            WHERE POSNR = IT_LIPS-DELPOSNR.
    ENDIF.
    ENDFORM.                    " GET_DATA
    Edited by: srk s on Jan 29, 2008 7:33 PM
    Edited by: Alvaro Tejada Galindo on Jan 29, 2008 9:49 AM

    Hi Satish,
    I have started the new program but i have trouble with the final internal table. Since i'm using For all entries, I have declared internal tables for each table. My incomplete new program is as follows(not sure if the logic is correct till what I have coded):
    *& Report  Z_SDFLOW                                                    *
    REPORT  Z_SDFLOW  NO STANDARD PAGE HEADING.
    ********* TABLES TO BE USED ***********************
    **** VBAK - SALES DOCUMENT HEADER
    * VBAP - SALES ITEM
    * VBFA - SALES DOCUMENT FLOW
    * KNA1- CUSTOMER MASTER
    * VBRK - BILLING DOCUMENT HEADER
    * VBRP - BLLING DOCUMENT ITEM
    * LIKP - DELIVERY HEADER
    * LIPS - DELIVERY ITEM
    * TOO1 - COMPANY CODES
    * SLIS.
    TYPE-POOLS: SLIS.
    ** STRUCTURE DECLARATIONS ********
    **STRUCTURE FOR ENQUIRY.
    **STRUCTURE FOR QUOTATION.
    **STRUCTURE FOR SALES ORDER HEADER- VBAK.
    TYPES: BEGIN OF XT_VBAK,
    VBELN TYPE VBAK-VBELN,     "SALES DOCUMENT NUMBER
    KUNNR TYPE VBAK-KUNNR,     " SOLD-TO-PARTY
    END OF XT_VBAK.
    **STRUCTURE FOR SALES ORDER  ITEM-VBAP
    TYPES: BEGIN OF XT_VBAP,
    POSNR TYPE VBAP-POSNR,     " SALES ITEM NUMBER
    MATNR TYPE VBAP-MATNR,     " MATERIAL NUMBER
    KWMENG TYPE VBAP-KWMENG,   " CUMMULATIVE ORDER QUANTITY IN SALES UNITS
    NETWR TYPE VBAP-NETWR,     " NET VALUE OF THE ORDER ITEM
    END OF XT_VBAP.
    ** STRUCTURE FOR DELIVERY HEADER -LIKP
    TYPES: BEGIN OF XT_LIKP,
    DELVBELN TYPE LIKP-VBELN,           "DELIVERY DOCUMENT NUMBER
    LFDAT TYPE LIKP-LFDAT,           " DELIVERY DATE
    END OF XT_LIKP.
    **STRUCTURE FOR DELIVERY ITEM - LIPS
    TYPES: BEGIN OF XT_LIPS,
    DELPOSNR TYPE LIPS-POSNR,           " DELIVERY ITEM NUMBER
    LFIMG TYPE LIPS-LFIMG,           " ACTUAL QUANTITY DELIVERED
    END OF XT_LIPS.
    **STRUCTURE FOR BILLING DOCUMENT HEADER -VBRK
    TYPES: BEGIN OF XT_VBRK,
    INVVBELN TYPE VBRK-VBELN,          "BILLING DOCUMENT NUMBER
    END OF XT_VBRK.
    **STRUCTURE FOR BILLING DOCUMENT ITEM - VBRP
    TYPES: BEGIN OF XT_VBRP,
    INVPOSNR TYPE VBRP-POSNR,          "BILLING ITEM NUMBER
    FKIMG TYPE VBRP-FKIMG,          "ACTUAL INVOICED QUANTITY
    INVNETWR TYPE VBRP-NETWR,          "NET VALUE OF THE BILLING ITEM
    END OF XT_VBRP.
    **STRUCTURE FOR FINAL INTERNAL TABLE.
    TYPES: BEGIN OF XT_FINAL,
    VBELN TYPE VBAK-VBELN,
    DELVBELN TYPE LIKP-VBELN,
    INVBELN TYPE VBRK-VBELN,
    KUNNR TYPE VBAK-KUNNR,
    POSNR TYPE VBAP-POSNR,
    DELPOSNT TYPE LIPS-POSNR,
    INVPOSNR TYPE VBRP-POSNR,
    MATNR TYPE VBAP-MATNR,
    KWMENG TYPE VBAP-KWMENG,
    NETWR TYPE VBAP-NETWR,
    INVNETWR TYPE VBRP-NETWR,
    LFDAT TYPE LIKP-LFDAT,
    LFIMG TYPE LIPS-LFIMG,
    FKIMG TYPE VBRP-FKIMG,
    NAME1 TYPE KNA1-NAME1,
    END OF XT_FINAL.
    **DATA DECLARATIONS
    DATA: V_NAME1 TYPE KNA1-NAME1,  "#EC *
          V_DELVBELN TYPE LIKP-VBELN,
          V_INVVBELN TYPE VBRK-VBELN,
          V_BUKRS TYPE T001-BUKRS,    "COMPANY CODE "#EC *
          V_AUDAT TYPE VBAK-AUDAT,
          V_VKORG TYPE VBAK-VKORG,
          V_VKGRP TYPE VBAK-VKGRP,
          V_SPART TYPE VBAK-SPART.
    **INTERNAL TABLE DECLARATIONS
    DATA: IT_VBAK TYPE STANDARD TABLE OF XT_VBAK,
          WA_VBAK TYPE XT_VBAK,
          IT_VBAP TYPE STANDARD TABLE OF XT_VBAP,
          WA_VBAP TYPE XT_VBAP,
          IT_LIKP TYPE STANDARD TABLE OF XT_LIKP,
          WA_LIKP TYPE XT_LIKP,
          IT_LIPS TYPE STANDARD TABLE OF XT_LIPS,
          WA_LIPS TYPE XT_LIPS,
          IT_VBRK TYPE STANDARD TABLE OF XT_VBRK,
          WA_VBRK TYPE XT_VBRK,
          IT_VBRP TYPE STANDARD TABLE OF XT_VBRP,
          WA_VBRP TYPE XT_VBRP,
          IT_FINAL TYPE STANDARD TABLE OF XT_FINAL,
          WA_FINAL TYPE XT_FINAL.
    **ALV DECLARATIONS
    DATA: IT_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,
          WA_FLDCAT TYPE SLIS_FIELDCAT_ALV,
          IT_LSTHDR TYPE SLIS_T_LISTHEADER,
          WA_LSTHDR TYPE SLIS_LISTHEADER,
          IT_EVENTS TYPE SLIS_T_EVENT,
          WA_EVENTS TYPE SLIS_ALV_EVENT,
          IT_SORT TYPE SLIS_T_SORTINFO_ALV,
          IT_LAYOUT TYPE SLIS_LAYOUT_ALV.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: S_BUKRS FOR V_BUKRS NO INTERVALS NO-EXTENSION,
                    S_VBELN FOR WA_VBAK-VBELN,  "SALES DOCUMENT NUMBER
                    S_KUNNR FOR WA_VBAK-KUNNR,  "SOLD-TO-PARTY
                    S_AUDAT FOR V_AUDAT,      "SALES DOCUMENT DATE
                    S_VKORG FOR V_VKORG,      "SALES ORGANISATION
                    S_VKGRP FOR V_VKGRP,      "SALES GROUP
                    S_SPART FOR V_SPART.      "DIVISION
    SELECTION-SCREEN END OF BLOCK b1.
    *****************SCREEN VALIDATION***************
    AT SELECTION-SCREEN.
    SELECT SINGLE BUKRS FROM T001 INTO V_BUKRS WHERE BUKRS IN S_BUKRS."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID COMPANY CODE'.
    ENDIF.
    SELECT SINGLE VBELN FROM VBAK INTO
              CORRESPONDING FIELDS OF WA_VBAK WHERE VBELN IN S_VBELN.
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER VALID SALES DOCUMENT NUMBER'.
    ENDIF.
    SELECT SINGLE KUNNR FROM VBAK INTO
              CORRESPONDING FIELDS OF WA_VBAK WHERE KUNNR IN S_KUNNR. "EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID CUSTOMER NUMBER'.
    ENDIF.
    SELECT SINGLE AUDAT FROM VBAK INTO V_AUDAT WHERE AUDAT IN S_AUDAT."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES DOCUMENT DATE'.
    ENDIF.
    SELECT SINGLE VKORG FROM VBAK INTO V_VKORG WHERE VKORG IN S_VKORG."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES ORGANISATION'.
    ENDIF.
    SELECT SINGLE VKGRP FROM VBAK INTO V_VKGRP WHERE VKGRP IN S_VKGRP."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES GROUP'.
    ENDIF.
    SELECT SINGLE SPART FROM VBAK INTO V_SPART WHERE SPART IN S_SPART."#EC *
    IF SY-SUBRC <> 0.
    MESSAGE E000(Z_SD2) WITH 'ENTER A VALID SALES DIVISION'.
    ENDIF.
    PERFORM GET_DATA.
    *&      Form  GET_DATA
    FORM GET_DATA .
    SELECT VBELN KUNNR
            INTO TABLE IT_VBAK
            FROM VBAK
            WHERE VBELN IN S_VBELN.
    *        BUKRS_VF IN S_BUKRS AND
    *        VKORG IN S_VKORG AND
    *        VKGRP IN S_VKGRP AND
    *        SPART IN S_SPART AND
    *        KUNNR IN S_KUNNR AND
    *        AUDAT IN S_AUDAT.
    IF IT_VBAK[] IS NOT INITIAL.
    SELECT POSNR MATNR KWMENG NETWR
            INTO TABLE IT_VBAP
            FROM VBAP
            FOR ALL ENTRIES IN IT_VBAK
            WHERE VBELN = IT_VBAK-VBELN.
    ENDIF.
    IF IT_VBAK[] IS NOT INITIAL.
    SELECT VBELN LFDAT
            INTO TABLE IT_LIKP
            FROM LIKP
            FOR ALL ENTRIES IN IT_VBAK
            WHERE VBELN = IT_VBAK-VBELN.
    ENDIF.
    IF IT_VBAP[] IS NOT INITIAL.
    SELECT POSNR LFIMG
            INTO TABLE IT_LIPS
            FROM LIPS
            FOR ALL ENTRIES IN IT_VBAP
            WHERE POSNR = IT_VBAP-POSNR.
    ENDIF.
    IF IT_LIKP[] IS NOT INITIAL.
    SELECT VBELN
            INTO TABLE IT_VBRK
            FROM VBRK
            FOR ALL ENTRIES IN IT_LIKP
            WHERE VBELN = IT_LIKP-DELVBELN.
    ENDIF.
    IF IT_LIPS[] IS NOT INITIAL.
    SELECT POSNR FKIMG NETWR
            INTO TABLE IT_VBRP
            FROM VBRP
            FOR ALL ENTRIES IN IT_LIPS
            WHERE POSNR = IT_LIPS-DELPOSNR.
    ENDIF.
    ENDFORM.                    " GET_DATA
    Code Formatted by: Alvaro Tejada Galindo on Jan 29, 2008 9:48 AM

  • What Program Structure to use?

    Dear All Expert,
                 I am looking for a suggestion on which program structure or combination of strutures that I can use for my programming of the following:
    1) My program had a few events triggering object. Start button click, Stop button click, Grid 1 to 4 button click, Serial received buffer true.
    2) With all these event cases, I had a sequence that can be programmed using State Machine. However, some of the state to state transistion had to be triggered by the event cases.
    3) When stop button is pressed, everything must stop and program to exit
                I had little experience with LabView. If possible, can link to some tutorial that is applicable or some example for me to continue with. Thanks a lot 

    Hi,
    JKI developped a tool for installing addons for Labview, and one of them is the JKI state Machine (free).
    You need to install VI package manager (http://jki.net/vipm), and then instal the JKI state machine (http://jki.net/state-machine)
    You will have then in your palette a new feature : JKI state machine.
    Best Regards, 
    V-F

  • Source of xslt mapping and XSD/ XMT target structures for standard Idocs

    Hi,
    I am working on R/3 - XI - ICH scenario. I need xslt mapping and XSD/ XML target structures for standard IDoc like PROACT01,DELFOR01, DELVRY03. I tried to search it on marketplace but couldn't find it there. As per configuration document, these things are shipped with XI mapping content in live cache CD. But I don't have this CD with me. Can anybody tell me the source for these target structures and mapping program. ( Please share marketplace, site link or send me across the mail [email protected])
    Thank you in advance.
    Anand More.

    Anand the other option is to import the corresponding idocs into your integration repository and then you can view the generated XSD there.
    As regards XSLT mapping, you need to basically first identify as to what form you want to transform your source idoc into.
    For some help on XSLT mapping check the following threads,
    https://www.sdn.sap.com/sdn/collaboration.sdn?contenttype=url&content=https%3A//forums.sdn.sap.com/topusers.jspa%3FforumID%3D44
    https://www.sdn.sap.com/sdn/collaboration.sdn?node=linkFnode1-6&contenttype=url&content=https://Process Integration (PI) & SOA Middleware
    Also have a look at my code samples,
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/xi-code-samples/generic xslt mapping in sap xi, part i.pdf
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9692eb84-0601-0010-5ca0-923b4fb8674a
    cheers
    Sameer

Maybe you are looking for

  • Questions on Weblogic RMI

    Hi           I've a few questions on WL RMI that I couldn't figure out from the           documentation.           Suppose I have a cluster containing Weblogic servers server1 and server2.           Server1 hosts an RMI object o1 that is bind to the

  • My current system is OS X 10.4.11 and I need a 10.5 to update my iPhone, where can I download the correct 10.5 update?

    My current system is OS X 10.4.11 and I need a 10.5 to update my iPhone, where can I download the correct 10.5 update?

  • Link of Pricing and Tax Procedure

    Dear Sir, I want to pick value (summation of some condition type) from pricing procedure to tax procedure. As like the value of basic price come automatically to tax as base amount..... in the same way i want that sum of some condition type will auto

  • BAPI_ACC_DOCUMENT_POST - Int.Order -E/KO/104/Order 400001234 does not exist

    Hi Experts, Am using BAPI_ACC_DOCUMENT_POST to post the docs, working fine, with populating min. fields in min. structures. But, in some cases, am populating INTERNAL ORDER into ACCOUNTGL-ORDERID field, but, am getting an error, saying E- KO-104--Ord

  • Creating Report on 3 infoobjects

    Hi, I am new to BW. I need to create a report on 3 customer info objects (converted to data targets) which is getting data from 3 different tables in R/3. They are 0CUSTOMER, 0CUST_SALES and 0CUST_COMPC. The 0CUST_SALES is needed to provide the Sales