I need heed help for Handle the JButton

hi, guys
I am writing a small program
It has name and number field.
It also has the first, privious, next , last and add buttons.
i want to load the myData.txt file to the name and number field.
and I want to make the buttons handle the events.
and when the application is closed, it will save the data into the files.
I can assign the the add button to save the files, and save the data when it is closed, but I can not make it save more than one record.
i need ur help to the rest of the buttons, and load the file back to the field.
andy suggestion would be great!
Thank !
here codes
   import javax.swing.*;
   import java.awt.event.*;
   import java.awt.*;
   import javax.swing.event.*;
   import java.io.*;
    public  class buttonAction extends JFrame
      private JLabel nameL;
      private JLabel numberL;               
      private JTextField name;
      private JTextField number;
      private JButton first;
      private JButton prev;
      private JTextField current;
      private JButton next;
      private JButton last;
      private JButton add;
      private JButton exit;
      private final int winw = 410;
      private final int winh = 200;
       private buttonAction()
         super("Wage Calculate");
         setSize(winw, winh);
         setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
         addWindowListener(new Closing());
         setLayout (new BorderLayout());
         loadData();        
         buildPanel();
         buildButtomButtons();
         setVisible(true);
       private void buildPanel()
         nameL = new JLabel("Name:");
         numberL = new JLabel("Number:");
         name = new JTextField(10);
         number = new  JTextField(5);
         JPanel panel =new JPanel();
         panel.setLayout(new GridLayout(2,1));
         panel.add(nameL);
         panel.add(name);
         panel.add(numberL);
         panel.add(number);
         add(panel, BorderLayout.NORTH);
       private void buildButtomButtons()
         first = new JButton("First");
         prev = new JButton("Prev");
         current = new JTextField(5);
         current.setEditable(false);
         next = new JButton("Next");
         last = new JButton("Last");
         add = new JButton("Add");
         exit = new JButton("Exit");
         JPanel button = new JPanel();
         first.addActionListener(new ButtonListener());
         prev.addActionListener(new ButtonListener());
         current.addActionListener(new ButtonListener());
         next.addActionListener(new ButtonListener());
         last.addActionListener(new ButtonListener());
         add.addActionListener(new ButtonListener());
         button.add(first);
         button.add(prev);
         button.add(current);
         button.add(next);
         button.add(last);
         button.add(add);
         add(button, BorderLayout.SOUTH);
        // save the data into the file when the application is close
       public class Closing extends WindowAdapter
          public void windowClosing(WindowEvent e)  
            try {
               PrintWriter out = new PrintWriter (new FileWriter("myData.txt"));
               out.println (name.getText());
               out.println(number.getText());
               out.close();
                catch (IOException ee) {
               // Happens if the file cannot be written to for any reason
                  JOptionPane.showMessageDialog(null, "Could not save the file " + ee.getMessage());
            System.exit(0);
       private void loadData()
         try {
            BufferedReader fileReader = new BufferedReader(new FileReader(new File("myData.txt")));
            String lineRead = fileReader.readLine();
              // I need help how to load the data
             catch (FileNotFoundException e)
               e.printStackTrace();
             catch (IOException e) {
               e.printStackTrace();
        //handle the first, previous, next, last, add buttons
       private class ButtonListener implements ActionListener
          public void actionPerformed(ActionEvent e)
            Object button = e.getSource();
            if (button == add)
               try
                  PrintWriter out = new PrintWriter (new FileWriter("myData.txt"));
                  out.println (name.getText());
                  out.println(number.getText());
                  out.close();
                   catch (IOException ee)
                  // Happens if the file cannot be written to for any reason
                     JOptionPane.showMessageDialog(null, "Could not save the file " + ee.getMessage());
                    //I need help for the first, privious and last buttons
       public static void main(String[] args)
         buttonAction pr = new buttonAction();
   }

are you trying to load a multi line textfile int a JTextField? If you try to load this in a while loop as you read the file, it will zoom through the file, and you will probably only see the last line of the file (or nothing if the last line is blank) in the jtextfield. Consider using a JTextArea or some other component that can hold multiple lines. Also your file reading method calls look wrong to me. You appear to read a line, then continually check if that one read line is null, and if not do a while loop, that looks to loop forever. Look at the java I/O examples for how to do this right.
Good luck

Similar Messages

  • Need help for understanding the behaviour of these 2 queries....

    Hi,
    I need your help for understanding the behaviour of following two queries.
    The requirement is to repeat the values of the column in a table random no of times.
    Eg. A table xyz is like -
    create table xyz as
    select 'A' || rownum my_col
    from all_objects
    where rownum < 6;
    my_col
    A1
    A2
    A3
    A4
    A5
    I want to repeat each of these values (A1, A2,...A5) multiple times - randomly decide. I have written the following query..
    with x as (select my_col, trunc(dbms_random.value(1,6)) repeat from xyz),
    y as (select level lvl from dual connect by level < 6)
    select my_col, lvl
    from x, y
    where lvl <= repeat
    order by my_col, lvl
    It gives output like
    my_col lvl
    A1     1
    A1     3
    A1     5
    A2     1
    A2     3
    A2     5
    A3     1
    A3     3
    A3     5
    A4     1
    A4     3
    A4     5
    A5     1
    A5     3
    A5     5
    Here in the output, I am not getting rows like
    A1     2
    A1     4
    A2     2
    A2     4
    Also, it has generated the same set of records for all the values (A1, A2,...,A5).
    Now, if I store the randomly-decided value in the table like ---
    create table xyz as
    select 'A' || rownum my_col, trunc(dbms_random.value(1,6)) repeat
    from all_objects
    where rownum < 6;
    my_col repeat
    A1     4
    A2     1
    A3     5
    A4     2
    A5     2
    And then run the query,
    with x as (select my_col, repeat from xyz),
    y as (select level lvl from dual connect by level < 6)
    select my_col, lvl
    from x, y
    where lvl <= repeat
    order by my_col, lvl
    I will get the output, exactly what I want ---
    my_col ....lvl
    A1     1
    A1     2
    A1     3
    A1     4
    A2     1
    A3     1
    A3     2
    A3     3
    A3     4
    A3     5
    A4     1
    A4     2
    A5     1
    A5     2
    Why the first approach do not generate such output?
    How can I get such a result without storing the repeat values?

    If I've understood your requirement, the below will achieve it:
    SQL> create table test(test varchar2(10));
    Table created.
    SQL> insert into test values('&test');
    Enter value for test: bob
    old   1: insert into test values('&test')
    new   1: insert into test values('bob')
    1 row created.
    SQL> insert into test values('&test');
    Enter value for test: terry
    old   1: insert into test values('&test')
    new   1: insert into test values('terry')
    1 row created.
    SQL> insert into test values('&test');
    Enter value for test: steve
    old   1: insert into test values('&test')
    new   1: insert into test values('steve')
    1 row created.
    SQL> insert into test values('&test');
    Enter value for test: roger
    old   1: insert into test values('&test')
    new   1: insert into test values('roger')
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select lpad(test,(ceil(dbms_random.value*10))*length(test),test) from test;
    LPAD(TEST,(CEIL(DBMS_RANDOM.VALUE*10))*LENGTH(TEST),TEST)
    bobbobbobbobbobbobbobbobbobbob
    terryterry
    stevestevesteve
    rogerrogerrogerrogerrogerrogerrogerrogerrogerYou can alter the value of 10 in the SQL if you want the potential for a higher number of names.
    Andy

  • Need some help here on the proper settings for quicktime exporting from imovie that won't degredate the footage from my handycam

    need some help here on the proper setting for quicktime exporting that won't denegrate my footage from handycam canon fs200

    What are the existing settings iMovie?
    Al

  • HI ALL SINCE TWO DAYS I AM DOWNLOADING VIBER BUT I AM NOT HAVING MY ACCESS CODE AND EVERY TIME I DELETE THE APPLICATION AND DOWNLOADING IT AGAIN BUT ALWAYS THE SAME RESULT PLEASE I NEED YOUR HELP FOR THE ACCESS CODE.MY PHONE NUMBER IS 0022996969896.THANKS

    HI ALL SINCE TWO DAYS I AM DOWNLOADING VIBER BUT I AM NOT HAVING MY ACCESS CODE AND EVERY TIME I DELETE THE APPLICATION AND DOWNLOADING IT AGAIN BUT ALWAYS THE SAME RESULT PLEASE I NEED YOUR HELP FOR THE ACCESS CODE.MY PHONE NUMBER IS 0022996969896.THANKS IN ADVANCE

    try this website this should help you http://helpme.viber.com/index.php?/Knowledgebase/List/Index/1/iphone

  • What does a new non-DE user need? | Help for a Wiki page

    Hey Archers,
    I'm using Arch with the Compiz Standalone Window Manager and I need some help for a project.
    It turns out (who knew) that computers need a lot more to run smoothly than just a desktop and applications. You need network managers, gtk themes and much much more. Now, Desktop Environments such as GNOME and KDE provide a lot of these programs built-in, good for them, but I'm looking to build my system as dependency-free as I can and the big DE's don't really provide that. Especially GNOME just ropes me in whenever I want to use the tiniest piece of it (darn you gnome-keyring).
    So I come to you fora, with a quest for information. I want to compile an overview of essential and useful applications with minimal dependencies that allow a CompizIndy user to build his system freely. And if I get enough information, I want to turn it into its own page for the Wiki so it becomes easier to get started with a birds-eye view of what you need to flesh out your system (not exclusively for CompizIndy btw). So please help me!
    What applications/daemons/tools should a new system install? I'm not asking which ones are the best or worst or your favorites, just which kinds do you need --that aren't covered in the install guide--?
    For example it's advisable to get:
    Panel/dock
    desktop manager
    network manager
    compositing manager
    a tool for managing removable devices (ntfs-3g etc)
    a packer/unpacker
    a screensaver
    power management
    alt-F2 runcommand
    custom keybindings
    a user switch/logout manager
    a volume manager
    etc.
    So what do you recommend? What do you need to get up and going?
    Hoping to hear from you guys and girls,
    Matthias
    PS: if I'm doubling up on anything, please let me know and save me effort and embarassment ^_^
    Last edited by Matsjo (2011-01-28 20:37:26)

    There are many threads on this, although individual ones asking for "the best app to do XXX". You could try searching those. Also Search for the LnF Awards threads. you might find a few ideas there. We also have wiki pages for light-weight applications which might be useful
    Panel/dock  none
    desktop manager none
    network manager netcfg
    compositing manager none or xcompmgr (for basic compositing)
    a tool for managing removable devices (ntfs-3g etc) udiskie or udev rules or devmon
    a packer/unpacker coreutils eg - tar, bzip etc with an alias called "ex" in .aliases
    a screensaver none
    power management ???
    alt-F2 runcommand gmrun
    custom keybindings xbindkeys
    a user switch/logout manager none
    a volume manager see udiskie....
    BTW, if this is for you, then simply install Arch and use a non DE based WM --- eventually you will figure out what you are missing

  • Need some help to unlock the Ipad. Cannot contact the previous owner he is in the shelter and I do not know were. After I restore the Ipad is asking that the previous owner has to remove it from his account

    need some help to unlock the Ipad. Cannot contact the previous owner he is in the shelter and I do not know were. After I restored the Ipad is asking that the previous owner has to remove it from his account

    Nobody on these boards or at Apple will unlock that device for you. Sorry.
    (117810)

  • I need some help for an explanation. Loop for 1 minute.

              int minute=1;
              long currentTime=System.currentTimeMillis();          
              long stoppingTime = currentTime + (minute * 60 * 1000);
              while (currentTime<stoppingTime) {
                   // do x;
                   currentTime=System.currentTimeMillis();
              }I want to have the loop to run for 1 minute. It does not seem to work.
    What did I miss? I need some help for an explanation.

    Ran:
    class PrintTimeAsProcess {
      public static void main(String[] argv)  throws Exception {
        int minute=1;
        long currentTime=System.currentTimeMillis();
        long stoppingTime = currentTime + (minute * 15 * 1000);
        System.out.println("START Time: "+currentTime);
        while (currentTime<stoppingTime) {
          currentTime=System.currentTimeMillis();
        System.out.println("END Time: "+currentTime);
    }Got:
    START Time: 1149278202718
    END Time: 1149278217718
    1149278217718
    -1149278202718
    15000

  • I need a program for camera.The androide has a program IP Cam View basic that has the fohu HA 425 and I get the cameras.I downlouded the IP camera viewer in the Aple but this program doesnt have the fuho HA 425. Which apple program is compatible?

    I need a program for camera.The androide has a program IP Cam View basic that has the fohu HA 425 and I get the cameras.I downlouded the IP camera viewer in the Aple but this program doesnt have the fuho HA 425. Which apple program is compatible?

    Hi,
    As far as I know, Sony Ericsson Z520, like a lot of the other cell phones, doesn�t support bluetooth serial communication.
    See:
    http://developer.sonyericsson.com/entry.jspa?externalID=138&categoryID=5
    BUT(!) You should double check this information.
    If you ask me, we have done similar project.
    We are working on hobby project � our robot use J2ME cell phone as on-board brain.
    And there is connection between this small robot and Linux-based PC.
    Communication was done via BlueTooth (in reality we use Linux implementation of BlueTooth stack and obexftp).
    BUT (!) We use Siemens S75 for this communication.
    I�m afraid that Siemens is the only manufacture, which implemented serial communication over bluetooth, embedded camera and non-usb socket.
    Also there are some Motorola phones, which implement serial communication over bluetooth.
    But � note that all Motorola phones use USB sockets and it will not be easy for you to make connection between such a phone and the robot.
    If you need just connection between cell phone and PC, then may be USB is OK too.
    Our robot project: www.RoboHobby.com

  • Hello, I need some help on renaming the title on mi web pages!

    Hello, I need some help on renaming the title on mi web pages! appear to be locked by the template and I would like to know if is posible rename each page with diferent title? Thanks,

    @ Gary: No, there is no need to specify an editable region in the page title.
    If you make a template from a page, by saving it as a template (using "save as template"), the page title is automatically made editable.
    @ Jesus: if you look into the code of your template or of any childpage, it should read like this:
    <!-- TemplateBeginEditable name="doctitle" -->
    <title>Mi PageTitle</title>
    <!-- TemplateEndEditable -->
    meaning that the page title is indeed editable.
    If it does not look like this, something went wrong.
    Maybe do a little test, save your page as a template and see if the code reads as above.
    It is important that you keep your templates in the Templates folder in your root folder
    Do not move the folder or change its name, otherwise it will not work.

  • Needed  sample program for emailing the report output

    hi all,
    neede sample program for emailing the report output

    Hi,
    Please refer this program for sending e-mail with attachment.
    ***INCLUDE ZHZLPP_CLZSN_DAILY_MIS_PRINT .
    *&      Form  print
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM print .
      DATA:  wa_output_options     TYPE ssfcompop,
             wa_control_parameters TYPE ssfctrlop,
             t_otfdata             TYPE ssfcrescl,
             t_pdf_tab             TYPE TABLE OF tline WITH HEADER LINE.
      DATA: t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE.
      DATA: w_filesize TYPE i.
      DATA: w_bin_filesize TYPE i.
      DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
      i_tline TYPE TABLE OF tline WITH HEADER LINE,
      v_form_name TYPE rs38l_fnam,
      v_len_in LIKE sood-objlen,
      w_return TYPE ssfcrescl.
      DATA : l_mean  TYPE p DECIMALS 2,
             l_mean1 TYPE p DECIMALS 2,
             l_mean2 TYPE p DECIMALS 2,
             l_mean3 TYPE p DECIMALS 4,
             temp    TYPE p DECIMALS 2,
             v_header LIKE zmisdisp3-remark,
             disp_d_kwh_mt TYPE zmisdisp5,
             disp_m_kwh_mt TYPE zmisdisp5,
             disp_d_mt_mw  TYPE zmisdisp5,
             disp_m_mt_mw  TYPE zmisdisp5,
             l_bptarget(16) TYPE p DECIMALS 2,
             l_act_d(16)    TYPE p DECIMALS 2,
             l_act_c(16)    TYPE p DECIMALS 2,
             l_pow_gen      TYPE p DECIMALS 2,
             l_pow_gen_d    TYPE p DECIMALS 2,
             l_pow_gen_c    TYPE p DECIMALS 2,
             l_no_of_days   TYPE p,
             disp_bptarget  TYPE zmisdisp5,
             disp_act_d     TYPE zmisdisp5,
             disp_act_c     TYPE zmisdisp5,
             disp_d_kwh     TYPE zmisdisp5,
             disp_c_kwh     TYPE zmisdisp5,
             disp_d_mw      TYPE zmisdisp5,
             disp_c_mw      TYPE zmisdisp5,
             disp_pow_gen_d TYPE zmisdisp5,
             disp_pow_gen_c TYPE zmisdisp5,
             disp_pow_gen   TYPE zmisdisp5,
             disp_ftd_h1    TYPE zmisdisp5,
             disp_ftd_h2    TYPE zmisdisp5,
             disp_ftd_h3    TYPE zmisdisp5,
             disp_ftd_h4    TYPE zmisdisp5,
             disp_ftd_h5    TYPE zmisdisp5,
             disp_ftd_o1    TYPE zmisdisp5,
             disp_ftd_o2    TYPE zmisdisp5,
             disp_ftd_o4    TYPE zmisdisp5,
             disp_ftd_o5    TYPE zmisdisp5,
             disp_***_o1    TYPE zmisdisp5,
             disp_***_o2    TYPE zmisdisp5,
             disp_***_o4    TYPE zmisdisp5,
             disp_***_o5    TYPE zmisdisp5,
             disp_cath_d    TYPE zmisdisp5,
             disp_cath_c    TYPE zmisdisp5,
             disp_anode_d   TYPE zmisdisp5,
             disp_anode_c   TYPE zmisdisp5,
             l_rec_con_d_kwh(16) TYPE p DECIMALS 2,
             l_rec_con_c_kwh(16) TYPE p DECIMALS 2,
             l_rec_con_d_mw(16)  TYPE p DECIMALS 2,
             l_rec_con_c_mw(16)  TYPE p DECIMALS 2,
             tot_kah      TYPE p DECIMALS 2,
             avg_kah      TYPE p DECIMALS 2,
             disp_tot_kah TYPE zmisdisp5,
             disp_avg_kah TYPE zmisdisp5,
             v_ftd_h1 TYPE p DECIMALS 2,
             v_ftd_h2 TYPE p DECIMALS 2,
             v_ftd_h3 TYPE p DECIMALS 2,
             v_ftd_h4 TYPE p DECIMALS 2,
             v_ftd_h5 TYPE p DECIMALS 2,
             v_ftd_o1 TYPE p DECIMALS 2,
             v_ftd_o2 TYPE p DECIMALS 2,
             v_ftd_o4 TYPE p DECIMALS 2,
             v_ftd_o5 TYPE p DECIMALS 2,
             v_***_o1 TYPE p DECIMALS 2,
             v_***_o2 TYPE p DECIMALS 2,
             v_***_o4 TYPE p DECIMALS 2,
             v_***_o5 TYPE p DECIMALS 2,
             l_cdiff1 LIKE imrg-cdiff,
             l_cdiff2 LIKE imrg-cdiff,
             l_cdiff3 LIKE imrg-cdiff,
             l_cdiff4 LIKE imrg-cdiff,
             l_path   LIKE rlgrap-filename,
             l_flag.
      DATA :prod_disp TYPE TABLE OF zmisdisp1 WITH HEADER LINE,
            keyp_disp TYPE TABLE OF zmisdisp2 WITH HEADER LINE,
            keyp_dis1 TYPE TABLE OF zmisdisp2 WITH HEADER LINE,
            rmat_disp TYPE TABLE OF zmisdisp4 WITH HEADER LINE,
            rcur_disp TYPE TABLE OF zmisdisp6 WITH HEADER LINE,
            rhrs_disp TYPE TABLE OF zmisdisp4 WITH HEADER LINE,
            brkd_disp TYPE TABLE OF zmisdisp7 WITH HEADER LINE.
      DEFINE fill_kpp.
        clear l_flag.
        loop at it_mic_data where kurztext = &1.
          l_mean1 = it_mic_data-mittelwert.
          l_mean = it_mic_data-mean.
          if l_flag = ' '.
            move : &2                     to keyp_disp-desc,
                   l_mean1                to keyp_disp-ftd.
            if     it_mic_data-kurztext = 'Ingot Pb SHG Zinc'.
              l_mean2 = v_mean_pbshg.
              move   l_mean2                to keyp_disp-avg.
            elseif it_mic_data-kurztext = 'Ingot Cu SHG Zinc'.
              l_mean2 = v_mean_cushg.
              move   l_mean2                to keyp_disp-avg.
            elseif it_mic_data-kurztext = 'Ingot Cd SHG Zinc'.
              l_mean2 = v_mean_cdshg.
              move   l_mean2                to keyp_disp-avg.
            elseif it_mic_data-kurztext = 'Ingot Fe SHG Zinc'.
              l_mean2 = v_mean_feshg.
              move   l_mean2                to keyp_disp-avg.
            elseif it_mic_data-kurztext = 'Ingot Zn SHG Zinc'.
              l_mean2 = v_mean_znshg.
              move   l_mean2                to keyp_disp-avg.
            else.
              move   l_mean                 to keyp_disp-avg.
            endif.
            if     it_mic_data-masseinhsw = 'GLI'.
              move 'g/l'                  to keyp_disp-unit.
            elseif it_mic_data-masseinhsw = 'PPM'.
              move 'ppm'                  to keyp_disp-unit.
            elseif it_mic_data-masseinhsw = 'NO'.
              move 'no'                   to keyp_disp-unit.
            else.
              move it_mic_data-masseinhsw to keyp_disp-unit.
            endif.
            append  keyp_disp.
            clear keyp_disp.
            move 'X' to l_flag.
          else.
            move : l_mean1                to keyp_disp-ftd.
            append  keyp_disp.
            clear keyp_disp.
          endif.
        endloop.
        if sy-subrc is not initial.
          move &2 to keyp_disp-desc.
          append  keyp_disp.
          clear keyp_disp.
        endif.
      END-OF-DEFINITION.
      DEFINE fill_kp1.
        clear l_flag.
        loop at it_mic_data where kurztext = &1.
          l_mean1 = it_mic_data-mittelwert.
          l_mean = it_mic_data-mean.
          if l_flag = ' '.
            move : &2                     to keyp_dis1-desc,
                   l_mean1                to keyp_dis1-ftd.
            if     it_mic_data-kurztext = 'Ingot Pb SHG Zinc'.
              l_mean2 = v_mean_pbshg.
              move   l_mean2                to keyp_dis1-avg.
            elseif it_mic_data-kurztext = 'Ingot Cu SHG Zinc'.
              l_mean2 = v_mean_cushg.
              move   l_mean2                to keyp_dis1-avg.
            elseif it_mic_data-kurztext = 'Ingot Cd SHG Zinc'.
              l_mean2 = v_mean_cdshg.
              move   l_mean2                to keyp_dis1-avg.
            elseif it_mic_data-kurztext = 'Ingot Fe SHG Zinc'.
              l_mean2 = v_mean_feshg.
              move   l_mean2                to keyp_dis1-avg.
            elseif it_mic_data-kurztext = 'Ingot Zn SHG Zinc'.
              l_mean3 = v_mean_znshg.
              move   l_mean3                to keyp_dis1-avg.
              clear  l_mean3.
              l_mean3 = it_mic_data-mittelwert.
              move   l_mean3                to keyp_dis1-ftd.
            else.
              move   l_mean                 to keyp_dis1-avg.
            endif.
            if     it_mic_data-masseinhsw = 'GLI'.
              move 'g/l'                  to keyp_dis1-unit.
            elseif it_mic_data-masseinhsw = 'PPM'.
              move 'ppm'                  to keyp_dis1-unit.
            elseif it_mic_data-masseinhsw = 'NO'.
              move 'no'                   to keyp_dis1-unit.
            else.
              move it_mic_data-masseinhsw to keyp_dis1-unit.
            endif.
            append  keyp_dis1.
            clear keyp_dis1.
            move 'X' to l_flag.
          else.
            if it_mic_data-kurztext = 'Ingot Zn SHG Zinc'.
              clear  l_mean3.
              l_mean3 = it_mic_data-mittelwert.
              move   l_mean3                to keyp_dis1-ftd.
            else.
              move : l_mean1                to keyp_dis1-ftd.
            endif.
            append  keyp_dis1.
            clear keyp_dis1.
          endif.
        endloop.
        if sy-subrc is not initial.
          move &2 to keyp_dis1-desc.
          append  keyp_dis1.
          clear keyp_dis1.
        endif.
      END-OF-DEFINITION.
    *FIRST PAGE
    ********PLANT HEADER
      MOVE 'CLZS HYDRO I PLANT - DAILY PRODUCTION REPORT' TO v_header.
    ********Production figure
      LOOP AT it_disp1.
        prod_disp-desc        = it_disp1-desc.
        prod_disp-d_plnmg     = it_disp1-d_plnmg.
        prod_disp-d_menge     = it_disp1-d_menge.
        prod_disp-u_plnmg     = it_disp1-u_plnmg.
        prod_disp-u_menge     = it_disp1-u_menge.
        prod_disp-avg         = it_disp1-avg.
        prod_disp-ask_rate    = it_disp1-ask_rate.
        prod_disp-m_plnmg     = it_disp1-m_plnmg.
        prod_disp-y_plnmg     = it_disp1-y_plnmg.
        prod_disp-y_menge     = it_disp1-y_menge.
        prod_disp-y_variance  = it_disp1-y_variance.
        APPEND prod_disp.
      ENDLOOP.
    ********Key performance parameters
      MOVE 'ROASTER :' TO keyp_disp-desc.
      APPEND  keyp_disp.
      fill_kpp '% S/S IN 45 DEG'            '  S/S in Calcine'.
      MOVE 'LEACHING :' TO keyp_disp-desc.
      APPEND  keyp_disp.
      fill_kpp '% S/S IN  CAL'              '  S/S in Calcine'.
      fill_kpp '%water soluble Zn'          '  W/S Zn in Jarosite Cake'.
      fill_kpp '%total Zn in HBF'           '  T/Zn in Jarosite cake'.
      fill_kpp 'ZINC IN CT'                 '  Zn in Conditioning tank'.
      fill_kpp 'g/l zn in neutral overflow' '  Zn in Electrolyte Prod (gpl)'.
      fill_kpp 'PPM CU IN PS25'             '  Purified Solution Cu'.
      fill_kpp 'PPM CADMIUM IN PS25'        '  Purified Solution Cd'.
      fill_kpp 'PPM COBALT IN PS25'         '  Purified Solution Co'.
      MOVE 'CELLHOUSE :' TO keyp_disp-desc.
      APPEND  keyp_disp.
      fill_kpp 'g/l zinc in cell feed'      '  Cell Feed Zinc gpl'.
      fill_kpp 'GPL ACID IN CELL FEED'      '  Cell Feed acidity gpl'.
      fill_kpp 'g/l manganese in cell feed' '  Cell Feed Mn gpl'.
      LOOP AT t_imrg_add_disp.
        MOVE:  t_imrg_add_disp-desc    TO keyp_disp-desc,
               t_imrg_add_disp-d_value TO keyp_disp-ftd,
               t_imrg_add_disp-c_value TO temp,
               temp                    TO keyp_disp-avg.
        IF t_imrg_add_disp-units = 'NO'.
          MOVE:  'no'                    TO keyp_disp-unit.
        ELSE.
          MOVE:  t_imrg_add_disp-units   TO keyp_disp-unit.
        ENDIF.
        APPEND keyp_disp.CLEAR keyp_disp.
      ENDLOOP.
      fill_kp1 'Ingot Pb SHG Zinc'          '  Ingot Pb SHG Zinc'.
      fill_kp1 'Ingot Cu SHG Zinc'          '  Ingot Cu SHG Zinc'.
      fill_kp1 'Ingot Cd SHG Zinc'          '  Ingot Cd SHG Zinc'.
      fill_kp1 'Ingot Fe SHG Zinc'          '  Ingot Fe SHG Zinc'.
      fill_kp1 'Ingot Zn SHG Zinc'          '  Ingot Zn SHG Zinc'.
    ********Cellhouse power
      CATCH SYSTEM-EXCEPTIONS bcd_zerodivide = 1.
        v_m_kwh_mt = v_ind8_m / cathode_recipt.
        v_m_mt_mw  = cathode_recipt / ( v_ind8_m / 24000 ).
      ENDCATCH.
      MOVE : v_d_kwh_mt TO disp_d_kwh_mt,
             v_m_kwh_mt TO disp_m_kwh_mt,
             v_d_mt_mw  TO disp_d_mt_mw,
             v_m_mt_mw  TO disp_m_mt_mw.
    *SECOND PAGE
    ********Raw Material
      LOOP AT it_disp3.
        rmat_disp-desc    = it_disp3-desc.
        rmat_disp-opstk   = it_disp3-opstk.
        rmat_disp-d_recpt = it_disp3-d_recpt.
        rmat_disp-u_recpt = it_disp3-u_recpt.
        rmat_disp-d_cons  = it_disp3-d_cons.
        rmat_disp-u_cons  = it_disp3-u_cons.
        rmat_disp-clstk   = it_disp3-clstk.
        APPEND rmat_disp.
      ENDLOOP.
    ********Work in Progress
    ********Finished Goods
    ********power consumption
      l_no_of_days = v_mm_en_dt+6(2).
      CATCH SYSTEM-EXCEPTIONS bcd_zerodivide = 1.
        l_bptarget   = ( v_bp_nrms_p * v_gross_d ) / l_no_of_days.
        l_act_d      = v_ind6_d + v_ind2_d - ( v_ind3_d + ( v_ind4_d / 2 ) ) - v_ind5_d.
        l_act_c      = v_ind6_m + v_ind2_m - ( v_ind3_m + ( v_ind4_m / 2 ) ) - v_ind5_m.
        l_pow_gen    = ( v_ind2_d / 1000 ) / v_ind7_d.
      ENDCATCH.
      l_pow_gen_d  = v_ind2_d / 1000.
      l_pow_gen_c  = v_ind9_m / 1000.
      l_rec_con_d_kwh = v_ind8_d.
      l_rec_con_c_kwh = v_ind8_m.
      l_rec_con_d_mw  = v_ind8_d / 24000.
      l_rec_con_c_mw  = v_ind8_m / ( 24000 * v_days_pased ).
      LOOP AT t_disp_curr.
        rcur_disp-time    = t_disp_curr-time.
        rcur_disp-current = t_disp_curr-current.
        rcur_disp-kah     = t_disp_curr-kah.
        APPEND rcur_disp.
        AT LAST.
          SUM.
          tot_kah = t_disp_curr-kah.
        ENDAT.
      ENDLOOP.
      avg_kah = tot_kah / '24'.
    *********************running hrs
      LOOP AT it_disp6.
        rhrs_disp-desc    = it_disp6-desc.
        rhrs_disp-opstk   = it_disp6-d_runhrs.
        rhrs_disp-d_recpt = it_disp6-m_runhrs.
        APPEND rhrs_disp.
      ENDLOOP.
      rhrs_disp-desc    = 'Turbo Generator'.
      rhrs_disp-opstk   = v_turbod.
      rhrs_disp-d_recpt = v_turboc.
      INSERT rhrs_disp INDEX 2.
    **********************BREAK_DOWN & OIL
      CLEAR value.
      LOOP AT itab2.
        IF itab2-equnr = 'NMZ-EH01G001'.
          PERFORM s_conversion_h.
          v_ftd_h1 = v_ftd_h1 + value.
          CLEAR value.
        ENDIF.
        IF itab2-equnr = 'NMZ-EH01G002'.
          PERFORM s_conversion_h.
          v_ftd_h2 = v_ftd_h2 + value.
          CLEAR value.
        ENDIF.
        IF itab2-equnr = 'NMZ-EH01V003'.
          PERFORM s_conversion_h.
          v_ftd_h3 = v_ftd_h3 + value.
          CLEAR value.
        ENDIF.
        IF itab2-equnr = 'NMZ-EH01V001'.
          PERFORM s_conversion_h.
          v_ftd_h4 = v_ftd_h4 + value.
          CLEAR value.
        ENDIF.
        IF itab2-equnr = 'NMZ-EH01V002'.
          PERFORM s_conversion_h.
          v_ftd_h5 = v_ftd_h5 + value.
          CLEAR value.
        ENDIF.
      ENDLOOP.
      LOOP AT t_oil.
        AT END OF ind.
          SUM.
          IF t_oil-ind = 1.
            v_***_o1 = t_oil-cdiff * 1000.
          ELSEIF t_oil-ind = 2.
            v_***_o2 = t_oil-cdiff * 1000.
          ELSEIF t_oil-ind = 3.
            v_***_o4 = t_oil-cdiff * 1000.
          ELSEIF t_oil-ind = 4.
            v_***_o5 = t_oil-cdiff * 1000.
          ENDIF.
        ENDAT.
        IF t_oil-idate = p_repdt.
          IF t_oil-ind = 1.
            l_cdiff1 = l_cdiff1 + t_oil-cdiff.
          ELSEIF t_oil-ind = 2.
            l_cdiff2 = l_cdiff2 + t_oil-cdiff.
          ELSEIF t_oil-ind = 3.
            l_cdiff3 = l_cdiff3 + t_oil-cdiff.
          ELSEIF t_oil-ind = 4.
            l_cdiff4 = l_cdiff4 + t_oil-cdiff.
          ENDIF.
        ENDIF.
      ENDLOOP.
      v_ftd_o1 = l_cdiff1 * 1000.
      v_ftd_o2 = l_cdiff2 * 1000.
      v_ftd_o4 = l_cdiff3 * 1000.
      v_ftd_o5 = l_cdiff4 * 1000.
    *********Breakdown details----3rd page
      LOOP AT itab INTO wa.
        CALL FUNCTION 'FLTP_CHAR_CONVERSION'
          EXPORTING
            decim = 0
            expon = 0
            input = wa-auszt
            ivalu = 'X'
          IMPORTING
            flstr = wk_char_auszt.
        CONDENSE wk_char_auszt NO-GAPS.
        wk_flt_auszt = wk_char_auszt.
        wk_flt_auszt = wk_flt_auszt / 3600.
        duration = wk_flt_auszt.
        brkd_disp-eqdesc = wa-eqktx.
        brkd_disp-nodesc = wa-qmtxt.
        brkd_disp-hrs    = duration.
        APPEND brkd_disp.
      ENDLOOP.
      MOVE : v_ftd_h1 TO disp_ftd_h1,
             v_ftd_h2 TO disp_ftd_h2,
             v_ftd_h3 TO disp_ftd_h3,
             v_ftd_h4 TO disp_ftd_h4,
             v_ftd_h5 TO disp_ftd_h5,
             v_ftd_o1 TO disp_ftd_o1,
             v_ftd_o2 TO disp_ftd_o2,
             v_ftd_o4 TO disp_ftd_o4,
             v_ftd_o5 TO disp_ftd_o5,
             v_***_o1 TO disp_***_o1,
             v_***_o2 TO disp_***_o2,
             v_***_o4 TO disp_***_o4,
             v_***_o5 TO disp_***_o5,
             l_bptarget      TO disp_bptarget,
             l_act_d         TO disp_act_d,
             l_act_c         TO disp_act_c,
             l_rec_con_d_kwh TO disp_d_kwh,
             l_rec_con_c_kwh TO disp_c_kwh,
             l_rec_con_d_mw  TO disp_d_mw,
             l_rec_con_c_mw  TO disp_c_mw,
             tot_kah         TO disp_tot_kah,
             avg_kah         TO disp_avg_kah,
             l_pow_gen       TO disp_pow_gen,
             l_pow_gen_d     TO disp_pow_gen_d,
             l_pow_gen_c     TO disp_pow_gen_c,
             v_cath_d        TO disp_cath_d,
             v_cath_c        TO disp_cath_c,
             v_anode_d       TO disp_anode_d,
             v_anode_c       TO disp_anode_c.
      wa_output_options-tdimmed = 'X'.
      wa_control_parameters-device = 'PRINTER'.
      wa_control_parameters-preview = 'X'.
      IF rb3 = 'X'.
        wa_control_parameters-getotf  = 'X'.
        wa_control_parameters-no_dialog = 'X'.
      ENDIF.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = 'ZHZLPP_CLZSN_DAILY_MIS'
        IMPORTING
          fm_name            = v_form_name
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      IF sy-subrc <> 0.
      ENDIF.
      CALL FUNCTION v_form_name
        EXPORTING
          control_parameters         = wa_control_parameters
          output_options             = wa_output_options
          user_settings              = 'X'
          header                     = v_header
          date                       = p_repdt
          l_bptarget                 = disp_bptarget
          l_act_d                    = disp_act_d
          l_act_c                    = disp_act_c
          disp_d_kwh                 = disp_d_kwh
          disp_c_kwh                 = disp_c_kwh
          disp_d_mw                  = disp_d_mw
          disp_c_mw                  = disp_c_mw
          disp_tot_kah               = disp_tot_kah
          disp_avg_kah               = disp_avg_kah
          disp_d_kwh_mt              = disp_d_kwh_mt
          disp_m_kwh_mt              = disp_m_kwh_mt
          disp_d_mt_mw               = disp_d_mt_mw
          disp_m_mt_mw               = disp_m_mt_mw
          disp_pow_gen               = disp_pow_gen
          disp_pow_gen_d             = disp_pow_gen_d
          disp_pow_gen_c             = disp_pow_gen_c
          disp_ftd_h1                = disp_ftd_h1
          disp_ftd_h2                = disp_ftd_h2
          disp_ftd_h3                = disp_ftd_h3
          disp_ftd_h4                = disp_ftd_h4
          disp_ftd_h5                = disp_ftd_h5
          disp_ftd_o1                = disp_ftd_o1
          disp_ftd_o2                = disp_ftd_o2
          disp_ftd_o4                = disp_ftd_o4
          disp_ftd_o5                = disp_ftd_o5
          disp_***_o1                = disp_***_o1
          disp_***_o2                = disp_***_o2
          disp_***_o4                = disp_***_o4
          disp_***_o5                = disp_***_o5
          disp_cath_d                = disp_cath_d
          disp_cath_c                = disp_cath_c
          disp_anode_d               = disp_anode_d
          disp_anode_c               = disp_anode_c
      IMPORTING
        job_output_info              = w_return           " .    
        TABLES
          prod_tab                   = prod_disp
          keyp_tab                   = keyp_disp
          remk_tab                   = it_remarks
          rmat_tab                   = rmat_disp
          rwip_tab                   = it_disp4
          rfng_tab                   = it_disp_fg
          rcur_tab                   = rcur_disp
          rhrs_tab                   = rhrs_disp
          brkd_tab                   = brkd_disp
          keyp_tab1                  = keyp_dis1
        EXCEPTIONS
          formatting_error           = 1
          internal_error             = 2
          send_error                 = 3
          user_canceled              = 4
          OTHERS                     = 5
      IF sy-subrc <> 0.
        MESSAGE 'Error in printing form' TYPE 'I'.
      ENDIF.
    ********Downloading in pdf format.
      IF rb3 = 'X'.
        IF l_usract <> 9.
          MOVE fullpath TO l_path.
          i_otf[] = w_return-otfdata[].
          CALL FUNCTION 'CONVERT_OTF'                   "
            EXPORTING
              format                = 'PDF'
              max_linewidth         = 132
            IMPORTING
              bin_filesize          = v_len_in
            TABLES
              otf                   = i_otf
              lines                 = i_tline
            EXCEPTIONS
              err_max_linewidth     = 1
              err_format            = 2
              err_conv_not_possible = 3
              OTHERS                = 4.
          IF sy-subrc <> 0.
          ENDIF.
          CALL FUNCTION 'WS_DOWNLOAD'
            EXPORTING
              bin_filesize            = v_len_in
              filename                = l_path
              filetype                = 'BIN'
            IMPORTING
              filelength              = w_filesize
            TABLES
              data_tab                = i_tline
            EXCEPTIONS
              file_open_error         = 1
              file_write_error        = 2
              invalid_filesize        = 3
              invalid_type            = 4
              no_batch                = 5
              unknown_error           = 6
              invalid_table_width     = 7
              gui_refuse_filetransfer = 8
              customer_error          = 9
              OTHERS                  = 10.
          IF sy-subrc = 0.
            MESSAGE 'File downloaded successfully' TYPE 'S'.
          ENDIF.
        ENDIF.
      ENDIF.
      IF sy-batch = 'X'.               " SENDING MAILS IF SCHEDULED IN BACKGROUND
        DATA: formname           TYPE tdsfname,
              fm_name            TYPE rs38l_fnam,
              control_parameters TYPE ssfctrlop,
              output_options     TYPE ssfcompop,
              job_output_info    TYPE ssfcrescl,
              otf_data           TYPE tsfotf.
        DATA: otf                TYPE TABLE OF itcoo WITH HEADER LINE,
              doctab_archive     TYPE TABLE OF docs WITH HEADER LINE,
              lines              TYPE TABLE OF tline WITH HEADER LINE,
              bin_filesize       TYPE i.
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
          EXPORTING
            formname           = 'ZHZLPP_CLZSN_DAILY_MIS'
          IMPORTING
            fm_name            = v_form_name
          EXCEPTIONS
            no_form            = 1
            no_function_module = 2
            OTHERS             = 3.
        IF sy-subrc <> 0.
        ENDIF.
        control_parameters-no_dialog = 'X'.
        control_parameters-getotf    = 'X'.
        CALL FUNCTION v_form_name
          EXPORTING
            control_parameters = control_parameters
            header             = v_header
            date               = p_repdt
            l_bptarget         = disp_bptarget
            l_act_d            = disp_act_d
            l_act_c            = disp_act_c
            disp_d_kwh         = disp_d_kwh
            disp_c_kwh         = disp_c_kwh
            disp_d_mw          = disp_d_mw
            disp_c_mw          = disp_c_mw
            disp_tot_kah       = disp_tot_kah
            disp_avg_kah       = disp_avg_kah
            disp_d_kwh_mt      = disp_d_kwh_mt
            disp_m_kwh_mt      = disp_m_kwh_mt
            disp_d_mt_mw       = disp_d_mt_mw
            disp_m_mt_mw       = disp_m_mt_mw
            disp_pow_gen       = disp_pow_gen
            disp_pow_gen_d     = disp_pow_gen_d
            disp_pow_gen_c     = disp_pow_gen_c
            disp_ftd_h1        = disp_ftd_h1
            disp_ftd_h2        = disp_ftd_h2
            disp_ftd_h3        = disp_ftd_h3
            disp_ftd_h4        = disp_ftd_h4
            disp_ftd_h5        = disp_ftd_h5
            disp_ftd_o1        = disp_ftd_o1
            disp_ftd_o2        = disp_ftd_o2
            disp_ftd_o4        = disp_ftd_o4
            disp_ftd_o5        = disp_ftd_o5
            disp_***_o1        = disp_***_o1
            disp_***_o2        = disp_***_o2
            disp_***_o4        = disp_***_o4
            disp_***_o5        = disp_***_o5
            disp_cath_d        = disp_cath_d
            disp_cath_c        = disp_cath_c
            disp_anode_d       = disp_anode_d
            disp_anode_c       = disp_anode_c
          IMPORTING
            job_output_info    = job_output_info
          TABLES
            prod_tab           = prod_disp
            keyp_tab           = keyp_disp
            remk_tab           = it_remarks
            rmat_tab           = rmat_disp
            rwip_tab           = it_disp4
            rfng_tab           = it_disp_fg
            rcur_tab           = rcur_disp
            rhrs_tab           = rhrs_disp
            brkd_tab           = brkd_disp
            keyp_tab1          = keyp_dis1
          EXCEPTIONS
            formatting_error   = 1
            internal_error     = 2
            send_error         = 3
            user_canceled      = 4
            OTHERS             = 5.
        IF sy-subrc = 0.
          otf_data = job_output_info-otfdata[].
          CALL FUNCTION 'CONVERT_OTF_2_PDF'
            IMPORTING
              bin_filesize           = bin_filesize
            TABLES
              otf                    = otf_data[]
              doctab_archive         = doctab_archive[]
              lines                  = lines[]
            EXCEPTIONS
              err_conv_not_possible  = 1
              err_otf_mc_noendmarker = 2
              OTHERS                 = 3.
          IF sy-subrc = 0.
            SUBMIT rsconn01 with mode = 'INT' AND RETURN.
    *                                    ----<<distrubution list>>----
            PERFORM mail_users TABLES lines USING 'MIS-HY1A' v_header.   " Donot put more than 8 email-ids
            PERFORM mail_users TABLES lines USING 'MIS-HY1B' v_header.   " in a distribution list
            PERFORM mail_users TABLES lines USING 'MIS-HY1C' v_header.
            PERFORM mail_users TABLES lines USING 'MIS-HY1D' v_header.
            PERFORM mail_users TABLES lines USING 'MIS-HY1E' v_header.
            PERFORM mail_users TABLES lines USING 'MIS-HY1F' v_header.
            PERFORM mail_users TABLES lines USING 'MIS-HY1G' v_header.
            PERFORM mail_users TABLES lines USING 'MIS-HY1H' v_header.
            PERFORM mail_users TABLES lines USING 'MIS-HY1I' v_header.
            PERFORM mail_users TABLES lines USING 'MIS-HY1J' v_header.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDFORM.                    " print
    *&      Form  get_download_path
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get_download_path .
      CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
        EXPORTING
          window_title      = 'Download as pdf file'
          default_extension = 'pdf'
        IMPORTING
          fullpath          = fullpath
          user_action       = l_usract.
      IF l_usract = '9'.
        STOP.
      ENDIF.
    ENDFORM.                    " get_download_path
    *&      Form  mail_users
    *       text
    *      -->P_LINES  text
    *      -->P_2153   text
    *      -->P_V_HEADER  text
    FORM mail_users  TABLES   p_lines STRUCTURE tline
                     USING    p_dist_list
                              p_v_header.
      CONSTANTS: c_raw TYPE so_obj_tp VALUE 'RAW',
                 c_pdf TYPE so_obj_tp VALUE 'PDF',
                 c_255 TYPE i VALUE 255,
                 c_134 TYPE i VALUE 134,
                 c_x   TYPE c VALUE 'X'.
      DATA: document_data LIKE sodocchgi1 ,
            tab_lines     TYPE i,
            contents_txt  TYPE TABLE OF solisti1 WITH HEADER LINE,
            contents_bin  TYPE TABLE OF solisti1 WITH HEADER LINE,
            packing_list  TYPE TABLE OF sopcklsti1 WITH HEADER LINE,
            object_header TYPE TABLE OF solisti1 WITH HEADER LINE,
            receivers     TYPE TABLE OF somlreci1 WITH HEADER LINE,
            l_str(255) ,
            v1 TYPE i,
            v2 TYPE i,
            v3 TYPE i.
      document_data-obj_name  = 'EMAIL'.
      document_data-obj_descr = p_v_header.  " SUBJECT LINE
      CONCATENATE 'Please find the attached SAP generated Daily Production Report for the day'
                  p_repdt+6(2)
                  p_repdt+4(2)
                  '.' p_repdt+0(4)
             INTO contents_txt.
      APPEND      contents_txt.
      CLEAR       contents_txt.
      APPEND      contents_txt.
      APPEND      contents_txt.
      DESCRIBE TABLE contents_txt LINES tab_lines.
      READ TABLE     contents_txt INDEX tab_lines.
      document_data-doc_size  = ( tab_lines - 1 ) * 255 + STRLEN( contents_txt ).
      document_data-doc_size  = tab_lines .
      CLEAR packing_list-transf_bin.
      packing_list-head_start = 1.
      packing_list-head_num   = 0.
      packing_list-body_start = 1.
      packing_list-body_num   = tab_lines.
      packing_list-doc_type   = c_raw.
      packing_list-doc_size   = document_data-doc_size.
      APPEND packing_list.
      LOOP AT p_lines.
        CLEAR l_str.
        l_str+0(2)   = p_lines-tdformat.
        l_str+2(132) = p_lines-tdline.
        v2 = v1 + c_134.
        IF v2 LE c_255.
          contents_bin-line+v1(c_134) = l_str. v1 = v2.
        ELSE.
          v3 = v2 - c_255.
          v2 = c_255 - v1.
          IF NOT v2 IS INITIAL.
            contents_bin-line+v1(v2) = l_str+0(v2).
          ENDIF.
          APPEND contents_bin.
          CLEAR  contents_bin.
          v1 = v3.
          v3 = 134 - v1.
          IF NOT v1 IS INITIAL.
            contents_bin-line+0(v1) = l_str+v3(v1).
          ENDIF.
        ENDIF.
      ENDLOOP.
      APPEND contents_bin.
      CLEAR  contents_bin.
      DESCRIBE TABLE contents_bin LINES tab_lines.
      READ     TABLE contents_bin INDEX tab_lines.
      CONCATENATE 'Hy-I Report'
                  p_repdt+6(2)
                  p_repdt+4(2)
                  '.' p_repdt+0(4)
                  '.pdf'
             INTO object_header.
      APPEND object_header.
      packing_list-transf_bin = c_x.
      packing_list-head_start = 1.
      packing_list-head_num   = 1.
      packing_list-body_start = 1.
      packing_list-body_num   = tab_lines.
      packing_list-doc_type   = c_pdf.
      packing_list-obj_name   = 'text1'.
      packing_list-obj_descr  = 'Production report'.
      packing_list-doc_size   = tab_lines * 255 + STRLEN( contents_bin ).
      APPEND packing_list.
      receivers-receiver      = p_dist_list.
      receivers-rec_type      = 'C'.
      APPEND receivers.
      CLEAR  receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          document_data              = document_data
          put_in_outbox              = ' '
          SENDER_ADDRESS             = 'CZPPPLG'
          SENDER_ADDRESS_TYPE        = 'B'
          commit_work                = 'X'
        TABLES
          packing_list               = packing_list
          object_header              = object_header
          contents_bin               = contents_bin
          contents_txt               = contents_txt
          receivers                  = receivers
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
      IF sy-subrc = 0.
        WAIT UP TO 2 SECONDS.
        SUBMIT rsconn01 with mode = 'INT' AND RETURN.
      ENDIF.
    ENDFORM.                    " mail_users

  • I need urgent help for the logic

    hi all,
    Initially, the requirement was to create PO regardless the Purchase Requisition based on the formula
    If (Open Qty + Current Stock) < Safety Stock ==>> THEN A PO NEEDS TO BE CREATED
    This is absolutely fine, this created the PO as per the above condition.
    OUR REQUIREMENT
    Modify the same program to create PO's only if there is any PR for that material . Meaning, turn all the PR's into PO. Also, when creating PO, the delivery date should be = (Current date - 7 days) when creating a PO for an PR(I think the table name is VETVG.)  Nothing else. We need to change the  IF condition in the following code .
    so can any one let me that what modification i need to do ie what logic i should use to get the requirement fullfilled.
    *Report  Z_STO_SAFETY_STOCK                                            *
    Program Name : Z_STO_SAFETY_STOCK                                    *
    Date         : 09.03.2007                                            *
    Programmer   : Rajdeep Kumar
    Last Change  : Van Tran                22/03/2007                    *
    Specification:                                                       *
    Program Type : Report                                                *
    Description  : Create STO requirement for Plant
    Transaction  : None                                                  *
    Input Files  : None                                                  *
    Output Files : None                                                  *
    Scheduling Issues :                                                  *
    Run Frequency :                                                      *
    Mod#    Date          By            Description                      *
    New   09.03.2007   Rajdeep Kumar     Created                         *
                       DEVK905890                                        *
    M01   20.03.2007   Rajdeep Kumar     Material Group Added to         *
                       DEVK905892        Selection Screen                *
    *Update 05.04.2007   DEVK906082        Added two new selection         *
                                         fields beskz and sobsl          *
                                         and is select statement         *
    REPORT  z_sto_safety_stock NO STANDARD PAGE HEADING.
    *&                       TABLES
    TABLES:
            t001w,
          marc.                                               " M01
            marc,                                               " M01
            mara.                                               " M01
    *&                     DATA DECLARATION
    DATA: BEGIN OF it_marc OCCURS 0,
            matnr LIKE marc-matnr,
            werks LIKE marc-werks,
            eisbe LIKE marc-eisbe,
          bstmi LIKE marc-bstmi,
            bstrf LIKE marc-bstrf,
            beskz LIKE marc-beskz,
            sobsl LIKE marc-sobsl,
          END OF it_marc.
    DATA: BEGIN OF it_mard OCCURS 0,
            matnr LIKE mard-matnr,
            werks LIKE mard-werks,
            labst LIKE mard-labst,
          END OF it_mard.
    DATA: BEGIN OF it_po OCCURS 0,
            ebeln LIKE ekko-ebeln,
            werks LIKE ekpo-werks,
            ebelp LIKE ekpo-ebelp,
            loekz LIKE ekpo-loekz,
            etenr LIKE eket-etenr,
            matnr LIKE ekpo-matnr,
            menge LIKE eket-menge,
            wemng LIKE eket-wemng,
          END OF it_po.
    DATA: BEGIN OF it_po_2 OCCURS 0,
            matnr LIKE ekpo-matnr,
            werks LIKE ekpo-werks,
            ebeln LIKE ekko-ebeln,
            ebelp LIKE ekpo-ebelp,
            loekz LIKE ekpo-loekz,
            etenr LIKE eket-etenr,
            menge LIKE eket-menge,
            wemng LIKE eket-wemng,
          END OF it_po_2.
    DATA: BEGIN OF it_po_pend OCCURS 0,
            matnr LIKE ekpo-matnr,
            werks LIKE ekpo-werks,
            pendi LIKE eket-menge,
          END OF it_po_pend.
    DATA: BEGIN OF wa_join OCCURS 0,
            ebeln LIKE ekko-ebeln,
            werks LIKE ekpo-werks,
            ebelp LIKE ekpo-ebelp,
            loekz LIKE ekpo-loekz,
            etenr LIKE eket-etenr,
            matnr LIKE ekpo-matnr,
            menge LIKE eket-menge,
            wemng LIKE eket-wemng,
          END OF wa_join.
    DATA : BEGIN OF itab_marc_mard OCCURS 0,
             werks  LIKE marc-werks,
             matnr  LIKE marc-matnr,
             eisbe  LIKE marc-eisbe,
           bstmi  LIKE marc-bstmi,
             bstrf  LIKE marc-bstrf,
             beskz  LIKE marc-beskz,
             sobsl  LIKE marc-sobsl,
             labst  LIKE mard-labst,
             menge  LIKE ekpo-menge,
             ordqty LIKE ekpo-menge,
           END OF itab_marc_mard.
    DATA: BEGIN OF it_sto OCCURS 0,
          werks LIKE mard-werks,
          matnr LIKE mard-matnr,
          orqty LIKE ekpo-menge,
          eisbe LIKE marc-eisbe,
        bstmi LIKE marc-bstmi,
          bstrf LIKE marc-bstrf,
          beskz LIKE marc-beskz,
          sobsl LIKE marc-sobsl,
          labst LIKE mard-labst,
          pendi LIKE eket-menge,
          END OF it_sto.
    DATA: ws_poheader            LIKE   bapimepoheader.
    DATA: ws_poheaderx           LIKE   bapimepoheaderx .
    DATA: ws_ebeln               TYPE   mepoheader-ebeln.
    DATA: ws_posnr               LIKE   ekpo-ebelp.
    DATA: ws_etenr               LIKE   eket-etenr VALUE '0001'.
    DATA: ws_purchaseorder       LIKE   ekko-ebeln.
    DATA: ws_flg1                TYPE   c. " VALUE 'X'.
    DATA: ws_flg2                TYPE   c.
    DATA: ws_flg3                TYPE   c.
    *-- For Handling Error Messages in BAPI
    DATA: tbl_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
    *-- For Item Details
    DATA: tbl_poitem LIKE bapimepoitem OCCURS 0 WITH HEADER LINE.
    DATA: tbl_poitemx LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE.
    DATA: tbl_posched LIKE bapimeposchedule OCCURS 0 WITH HEADER LINE.
    DATA: tbl_poschedx LIKE bapimeposchedulx OCCURS 0 WITH HEADER LINE.
    *&                       CONSTANTS
    CONSTANTS:   ws_flg            TYPE   c   VALUE 'X'.
    CONSTANTS:   c_unistruct(2)    TYPE   c   VALUE 'Z3'. "For UNISTRUCT STO
    *&                      SELECTION-SCREEN
    SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_werks FOR t001w-werks,
                  s_matnr FOR marc-matnr.                     " M01
                    s_matnr FOR marc-matnr,                     " M01
                    s_matkl FOR mara-matkl,                     " M01
                    s_beskz FOR marc-beskz,
                    s_sobsl FOR marc-sobsl.
    PARAMETERS:     p_test  TYPE check.
    SELECTION-SCREEN : END OF BLOCK b1.
    *&                      START OF SELECTION EVENT
    START-OF-SELECTION.
    Get the Safety Stock & Minimum Lot Size for the materials
      PERFORM get_plant_data.
    Get the Quantities in stock
      PERFORM get_stock_data.
    Determine the open quantities for the materials concerned
    [EKKO, EKET, EKPO]
      PERFORM get_open_quantities.
    PERFORM open_quantities.
    Determine overall the quantities required for each material
      PERFORM determine_mat_qty_required.
    Print the details
      PERFORM print_details.
      IF p_test EQ space.
      PO is created for each plant.
      Create the PO required.
        PERFORM create_po.
      Create the PO's for each plant with the materials required
       PERFORM create_header_item.
      Bapi call to create a Purchase order
       PERFORM create_purhase_order.
      ENDIF.
    END-OF-SELECTION.
    TOP-OF-PAGE.
      PERFORM print_header.
    *&      Form  get_plant_data
          To get the Safety Stock
    -->  p1        text
    <--  p2        text
    FORM get_plant_data .
    start                                                     " M01
    SELECT      matnr werks eisbe bstmi
    INTO TABLE  it_marc
    FROM        marc
    WHERE       matnr IN s_matnr AND
                werks IN s_werks AND
                eisbe GT 0.
    end                                                       " M01
    start                                                     " M01
      SELECT      marc~matnr werks eisbe bstrf beskz sobsl
                                                              " bstmi
      INTO TABLE  it_marc
      FROM        marc AS marc
      INNER JOIN  mara AS mara
      ON          maramatnr EQ marcmatnr
      WHERE       marc~matnr IN s_matnr AND
                  werks      IN s_werks AND
                  matkl      IN s_matkl AND
                  beskz      IN s_beskz AND
                  sobsl      IN s_sobsl AND
                  eisbe      GT 0.
    end                                                       " M01
    ENDFORM.                    " get_plant_data
    *&      Form  get_stock_data
         To get the Current Stock
    -->  p1        text
    <--  p2        text
    FORM get_stock_data .
      DATA: BEGIN OF lt_mard OCCURS 0,
              matnr LIKE mard-matnr,
              werks LIKE mard-werks,
              lgort LIKE mard-lgort,
              labst LIKE mard-labst,
            END OF lt_mard.
      CHECK NOT it_marc[] IS INITIAL.
      SELECT      matnr werks lgort labst
      INTO TABLE  lt_mard
      FROM        mard
      FOR         ALL ENTRIES IN it_marc
      WHERE       matnr EQ it_marc-matnr AND
                  werks EQ it_marc-werks.
      SORT lt_mard BY matnr werks.
      LOOP AT lt_mard.
        AT NEW werks.
          it_mard-matnr = lt_mard-matnr.
          it_mard-werks = lt_mard-werks.
        ENDAT.
        it_mard-labst = it_mard-labst + lt_mard-labst.
        AT END OF werks.
          APPEND it_mard.
          CLEAR  it_mard.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " get_stock_data
    *&      Form  open_quantities
          text
    -->  p1        text
    <--  p2        text
    FORM open_quantities .
    Storing MARC and MARD data in an internal table to find the open
    quantities
      LOOP AT it_marc.
        itab_marc_mard-matnr = it_marc-matnr.
        itab_marc_mard-werks = it_marc-werks.
        itab_marc_mard-eisbe = it_marc-eisbe.
      itab_marc_mard-bstmi = it_marc-bstmi.
        itab_marc_mard-bstrf = it_marc-bstrf.
        itab_marc_mard-beskz = it_marc-beskz.
        itab_marc_mard-sobsl = it_marc-sobsl.
        READ TABLE it_mard WITH KEY matnr = it_marc-matnr.
        IF sy-subrc EQ 0.
          itab_marc_mard-labst = it_mard-labst.
        ENDIF.
        APPEND itab_marc_mard.
        CLEAR itab_marc_mard.
      ENDLOOP.
      CHECK NOT itab_marc_mard[] IS INITIAL.
    Join EKKO EKPO
      SELECT a~ebeln
             b~ebelp
             b~werks
             b~matnr
             b~menge
             c~etenr
             c~wamng
             INTO CORRESPONDING FIELDS OF TABLE it_po
      FROM ekpo AS b
      INNER JOIN ekko AS a
      ON aebeln = bebeln
      INNER JOIN eket AS c
      ON bebeln = cebeln AND bebelp = cebelp
      FOR ALL ENTRIES IN itab_marc_mard
      WHERE b~matnr = itab_marc_mard-matnr AND
            b~werks IN s_werks .
      DATA : t_menge TYPE ekpo-menge . "local variable
    *Store the contents of it_po to the work area to get the minimum order
    *quantity
      wa_join[] = it_po[].
      LOOP AT it_po.
    delete the entries where MENGE = WAMNG
        DELETE it_po WHERE menge = it_po-wemng.
        LOOP AT wa_join WHERE matnr = it_po-matnr
                               AND werks = it_po-werks.
          t_menge = t_menge + wa_join-menge.
        ENDLOOP.
        it_po-menge = t_menge.
        MODIFY TABLE it_po TRANSPORTING menge.
        CLEAR  :t_menge.
      ENDLOOP.
    Once you get the quantities delete the repeating materials for the
    plant.
      DELETE ADJACENT DUPLICATES FROM it_po COMPARING werks matnr.
      SORT it_po BY matnr.
      LOOP AT itab_marc_mard.
        READ TABLE it_po WITH KEY matnr = itab_marc_mard-matnr
            APPEND it_sto.
        ELSE.
          WRITE:/ 'There are no open quantities to create Purchase order'.
        ENDIF.
        CLEAR it_sto.
      ENDLOOP.                         werks = itab_marc_mard-werks BINARY
    SEARCH.
        itab_marc_mard-ordqty = itab_marc_mard-labst + it_po-menge .
         If Open quantiy + Current Stock < Safety Stock
        IF itab_marc_mard-ordqty LE itab_marc_mard-eisbe.
         Minimum order qty = Safety Stock - (Open qty + current stock)
          itab_marc_mard-ordqty = itab_marc_mard-eisbe - ( it_po-menge +
    itab_marc_mard-labst )  .
           Move all the contents to the internal table it_sto ie Plant,
    Material and the Min Order Qty
           so that we can create PO based on this internal table
          it_sto-matnr = itab_marc_mard-matnr.
          it_sto-werks = itab_marc_mard-werks.
          it_sto-orqty = itab_marc_mard-ordqty.
    ENDFORM.                    " open_quantities
    *&      Form  CREATE_HEADER_ITEM
          text
    FORM create_header_item.
      LOOP AT it_sto.
    *--- Document date with flag
        ws_poheader-doc_date             = sy-datum.
        ws_poheaderx-doc_date            = ws_flg.
    *--- Document type with flag
        ws_poheader-doc_type             = 'Z3'(c01).
        ws_poheaderx-doc_type            = ws_flg.
    *--- Purchasing group with Flag
        ws_poheader-pur_group            = '005'.   " hardcoded
        ws_poheaderx-pur_group           =  ws_flg.
    *--- Purchasing Organization with flag
        ws_poheader-purch_org            = '2000'.
        ws_poheaderx-purch_org           = ws_flg.
    *--- Supply plant with flag
        ws_poheader-suppl_plnt           = '2000'.
        ws_poheaderx-suppl_plnt          = ws_flg.
    *--- Company Code with flag
        ws_poheader-comp_code            = '2000'.
        ws_poheaderx-comp_code           = ws_flg.
    *<--- assinging new item No.
        ws_posnr = ws_posnr + 10.
    *POPULATE ITEM DATA.
        tbl_poitem-po_item                 = ws_posnr.
        tbl_poitem-material                = it_sto-matnr.
        tbl_poitem-item_cat                = 'U'(c02).
        tbl_poitem-plant                   = it_sto-werks.
        tbl_poitem-quantity                = it_sto-orqty.
        APPEND tbl_poitem.
        CLEAR  tbl_poitem.
    *POPULATE ITEM FLAG TABLE
        tbl_poitemx-po_item                = ws_posnr.
        tbl_poitemx-po_itemx               = ws_flg.
        tbl_poitemx-material               = ws_flg.
        tbl_poitemx-plant                  = ws_flg.
        tbl_poitemx-item_cat               = ws_flg.
        tbl_poitemx-quantity               = ws_flg.
        APPEND tbl_poitemx.
        CLEAR  tbl_poitemx.
      ENDLOOP.
    ENDFORM.                    "CREATE_PO
    *&      Form
          text
    -->  p1        text
    <--  p2        text
    FORM create_purhase_order .
      CLEAR:  tbl_poitem,
              tbl_poitemx,
              ws_poheader,
              ws_poheaderx.
      REFRESH:  tbl_poitem,
                tbl_poitemx.
      CLEAR  : tbl_return.
      REFRESH: tbl_return.
    *<--- Bapi to create Purchase order
      IF NOT tbl_poitem[] IS INITIAL.
        CALL FUNCTION 'BAPI_PO_CREATE1'
          EXPORTING
            poheader         = ws_poheader
            poheaderx        = ws_poheaderx
          IMPORTING
            exppurchaseorder = ws_purchaseorder
          TABLES
            return           = tbl_return
            poitem           = tbl_poitem
            poitemx          = tbl_poitemx.
        READ TABLE tbl_return WITH KEY type = 'E'.
    *<--- Bapi to commit the changes
        IF sy-subrc <> 0.
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
            EXPORTING
              wait = 'X'.
        ENDIF.
      ENDIF.
      LOOP AT tbl_return.
    *<--- Ignore the warning messages
        IF tbl_return-type = 'W'.
          CONTINUE.
        ENDIF.
        FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
        IF tbl_return-type = 'S'.
          FORMAT COLOR COL_POSITIVE ON.
        ELSEIF tbl_return-type = 'W'.
          FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
        ELSEIF tbl_return-type = 'E'.
          FORMAT COLOR COL_NEGATIVE INTENSIFIED OFF.
        ENDIF.
        WRITE:/3 tbl_return-type,12 tbl_return-id,20(85)  tbl_return-message
               86(10) tbl_return-field,95(20) tbl_return-system.
        FORMAT COLOR OFF.
      ENDLOOP.
    ENDFORM.                    " create_purhase_order
    *&      Form  get_open_quantities
          text
    -->  p1        text
    <--  p2        text
    FORM get_open_quantities .
      CHECK NOT it_mard[] IS INITIAL.
      SELECT      ekkoebeln ekpoebelp ekpowerks ekpomatnr
                  ekpomenge eketetenr eket~wemng
                  INTO CORRESPONDING FIELDS OF TABLE it_po
      FROM        ekko AS ekko
      INNER JOIN  ekpo AS ekpo
      ON          ekpoebeln EQ ekkoebeln
      INNER JOIN  eket AS eket
      ON          eketebeln EQ ekpoebeln AND
                  eketebelp EQ ekpoebelp
      FOR         ALL ENTRIES IN it_mard
      WHERE       ekko~bstyp EQ 'F'             AND
                  ekko~bsart EQ 'Z3'            AND
                  ekko~bsakz EQ 'T'             AND
                  ekko~loekz EQ space           AND
                  ekpo~matnr EQ it_mard-matnr   AND
                  ekpo~werks EQ it_mard-werks   AND
                  ekpo~loekz EQ space           AND
                  ekpo~elikz EQ space.
      SORT it_po BY ebeln ebelp etenr.
    delete entries where the schedule is complete, else copy to new table
      LOOP AT it_po.
        IF it_po-wemng GE it_po-menge.
          DELETE it_po.
        ELSE.
          MOVE-CORRESPONDING it_po TO it_po_2.
          APPEND it_po_2.
          CLEAR  it_po_2.
        ENDIF.
      ENDLOOP.
      SORT it_po_2 BY matnr werks.
    To determine the pending quantities of the materials at plant level
      LOOP AT it_po_2.
        AT NEW werks.
          it_po_pend-matnr = it_po_2-matnr.
          it_po_pend-werks = it_po_2-werks.
        ENDAT.
        it_po_pend-pendi = it_po_pend-pendi + it_po_2-menge - it_po_2-wemng.
        AT END OF werks.
          APPEND it_po_pend.
          CLEAR  it_po_pend.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " get_open_quantities
    *&      Form  determine_mat_qty_required
          text
    -->  p1        text
    <--  p2        text
    FORM determine_mat_qty_required .
      DATA: lv_eisbe LIKE marc-eisbe,
            lv_labst LIKE mard-labst,
            lv_menge LIKE eket-menge,
          lv_bstmi_old LIKE marc-bstmi,
            lv_bstrf_old LIKE marc-bstrf,
            lv_beskz_old LIKE marc-beskz,
            lv_sobsl_old LIKE marc-sobsl,
            lv_pendi LIKE eket-menge,
            lv_total_conf     LIKE ekpo-menge,
          lv_bstmi          LIKE marc-bstmi,
          lv_min_qty        LIKE marc-bstmi,
            lv_bstrf          LIKE marc-bstrf,
            lv_min_qty        LIKE marc-bstrf,
            lv_qty_req        LIKE mard-labst,
            lv_remainder      TYPE i.
      LOOP AT it_marc.
      safety stock
        lv_eisbe = it_marc-eisbe.
       lv_bstmi_old = it_marc-bstmi.
         lv_bstrf_old = it_marc-bstrf.
         lv_beskz_old = it_marc-beskz.
         lv_sobsl_old = it_marc-beskz.
        READ TABLE it_mard
        WITH KEY matnr = it_marc-matnr
                 werks = it_marc-werks
                 BINARY SEARCH.
        IF sy-subrc EQ 0.
        qty onhand
          lv_labst = it_mard-labst.
        ELSE.
          CLEAR lv_labst.
        ENDIF.
        READ TABLE it_po_pend
        WITH KEY matnr = it_marc-matnr
                 werks = it_marc-werks
                 BINARY SEARCH.
        IF sy-subrc EQ 0.
        PO pending qty
          lv_pendi = it_po_pend-pendi.
        ELSE.
          CLEAR lv_pendi.
        ENDIF.
      Total qty on hand & PO qty pending
        lv_total_conf = lv_labst + lv_pendi.
      Now determine if a PO is required for the material concerned.
        IF lv_total_conf < lv_eisbe.
          it_sto-matnr = it_marc-matnr.
          it_sto-werks = it_marc-werks.
          it_sto-eisbe = lv_eisbe.
        it_sto-bstmi = lv_bstmi_old.
          it_sto-bstrf = lv_bstrf_old.
          it_sto-beskz = lv_beskz_old.
          it_sto-sobsl = lv_sobsl_old.
          it_sto-labst = lv_labst.
          it_sto-pendi = lv_pendi.
        Actual Qty Required
          lv_qty_req = lv_eisbe - lv_total_conf.
         IF it_marc-bstmi IS INITIAL.
           IF it_marc-bstrf IS INITIAL.
            it_sto-orqty = lv_qty_req.
          ELSE.
           lv_bstmi = it_marc-bstmi.
           lv_min_qty = it_marc-bstmi.
             lv_bstrf = it_marc-bstrf.
             lv_min_qty = it_marc-bstrf.
            DO.
              IF lv_qty_req <= lv_min_qty.
                lv_qty_req = lv_min_qty.
                it_sto-orqty = lv_qty_req.
                EXIT.
              ELSE.
               lv_min_qty = lv_min_qty + lv_bstmi.
                 lv_min_qty = lv_min_qty + lv_bstrf.
              ENDIF.
            ENDDO.
          ENDIF.
          APPEND it_sto.
          CLEAR  it_sto.
        ENDIF.
      ENDLOOP.
      SORT it_sto BY werks matnr.
    ENDFORM.                    " determine_mat_qty_required
    *&      Form  print_details
          text
    -->  p1        text
    <--  p2        text
    FORM print_details .
      LOOP AT it_sto.
        WRITE:/ it_sto-werks UNDER text-h01,
                it_sto-matnr UNDER text-h02,
                it_sto-orqty UNDER text-h03,
                it_sto-eisbe UNDER text-h04,
              it_sto-bstmi UNDER text-h05,
                it_sto-bstrf UNDER text-h05,
                it_sto-labst UNDER text-h06,
                it_sto-pendi UNDER text-h07.
      ENDLOOP.
    ENDFORM.                    " print_details
    *&      Form  print_header
          text
    -->  p1        text
    <--  p2        text
    FORM print_header .
      WRITE:  AT 001 text-h01,
                 015 text-h02,
               030 text-h03,
               050 text-h04,
               070 text-h05,
               090 text-h06,
               110 text-h07.
                 030 text-h03 RIGHT-JUSTIFIED,
                 050 text-h04 RIGHT-JUSTIFIED,
                 070 text-h05 RIGHT-JUSTIFIED,
                 090 text-h06 RIGHT-JUSTIFIED,
                 110 text-h07 RIGHT-JUSTIFIED.
      NEW-LINE.
    ENDFORM.                    " print_header
    *&      Form  create_po
          text
    -->  p1        text
    <--  p2        text
    FORM create_po .
    *-Document date with flag
      ws_poheader-doc_date             = sy-datum.
      ws_poheaderx-doc_date            = ws_flg.
    *-Document type with flag
      ws_poheader-doc_type             = 'Z3'(c01).
      ws_poheaderx-doc_type            = ws_flg.
    *-Purchasing group with Flag
      ws_poheader-pur_group            = '005'.   " hardcoded
      ws_poheaderx-pur_group           =  ws_flg.
    *-Purchasing Organization with flag
      ws_poheader-purch_org            = '2000'.
      ws_poheaderx-purch_org           = ws_flg.
    *-Supply plant with flag
      ws_poheader-suppl_plnt           = '2000'.
      ws_poheaderx-suppl_plnt          = ws_flg.
    *-Company Code with flag
      ws_poheader-comp_code            = '2000'.
      ws_poheaderx-comp_code           = ws_flg.
      LOOP AT it_sto.
        AT NEW werks.
          CLEAR  tbl_poitem.
          CLEAR  tbl_poitemx.
          CLEAR  tbl_return.
          CLEAR  tbl_posched.
          CLEAR  tbl_poschedx.
          REFRESH tbl_poitem.
          REFRESH tbl_poitemx.
          REFRESH tbl_return.
          REFRESH tbl_posched.
          REFRESH tbl_poschedx.
          CLEAR ws_posnr.
        ENDAT.
        ws_posnr = ws_posnr + 10.
      Item Data
        tbl_poitem-po_item                 = ws_posnr.
        tbl_poitem-material                = it_sto-matnr.
        tbl_poitem-item_cat                = 'U'(c02).
        tbl_poitem-plant                   = it_sto-werks.
        tbl_poitem-quantity                = it_sto-orqty.
        APPEND tbl_poitem.
        CLEAR  tbl_poitem.
      Item X Data
        tbl_poitemx-po_item                = ws_posnr.
        tbl_poitemx-po_itemx               = ws_flg.
        tbl_poitemx-material               = ws_flg.
        tbl_poitemx-plant                  = ws_flg.
        tbl_poitemx-item_cat               = ws_flg.
        tbl_poitemx-quantity               = ws_flg.
        APPEND tbl_poitemx.
        CLEAR  tbl_poitemx.
      Schedule Data
        tbl_posched-po_item = ws_posnr.
        tbl_posched-sched_line = '0001'.
        tbl_posched-delivery_date = sy-datum.
        tbl_posched-quantity = it_sto-orqty.
        APPEND tbl_posched.
        CLEAR  tbl_posched.
      Schedule Data X
        tbl_poschedx-po_item = ws_posnr.
        tbl_poschedx-po_itemx = ws_flg.
        tbl_poschedx-sched_line = '0001'.
        tbl_poschedx-sched_linex = ws_flg.
        tbl_poschedx-delivery_date = ws_flg.
        tbl_poschedx-quantity = ws_flg.
        APPEND tbl_poschedx.
        CLEAR  tbl_poschedx.
        AT END OF werks.
        Create the PO
          CALL FUNCTION 'BAPI_PO_CREATE1'
            EXPORTING
              poheader         = ws_poheader
              poheaderx        = ws_poheaderx
            IMPORTING
              exppurchaseorder = ws_purchaseorder
            TABLES
              return           = tbl_return
              poitem           = tbl_poitem
              poitemx          = tbl_poitemx
              poschedule       = tbl_posched
              poschedulex      = tbl_poschedx.
          LOOP AT tbl_return WHERE type EQ 'E' OR type EQ 'A'.
            EXIT.
          ENDLOOP.
        If Loop is false - then no error occurred
          IF sy-subrc NE 0.
          No Errors - Commit
            CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
              EXPORTING
                wait = 'X'.
          ENDIF.
          SKIP.
          LOOP AT tbl_return.
            FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
            IF tbl_return-type = 'E' OR tbl_return-type = 'A'.
              FORMAT COLOR COL_NEGATIVE INTENSIFIED OFF.
            ELSEIF tbl_return-type = 'W'.
              FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
            ELSE.
              FORMAT COLOR COL_POSITIVE ON.
            ENDIF.
            WRITE:/3 tbl_return-type,12 tbl_return-id,20(85)
    tbl_return-message,
                   86(10) tbl_return-field,95(20) tbl_return-system.
            FORMAT COLOR OFF.
          ENDLOOP.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " create_po

    Hi,
    first you can store these 2 dates into some internal table sat it_sobid  and it_ObjectID.Now
    sort  it_sobid ascending.
    loop at  it_ObjectID.
    Read date from  it_sobid  binary search index sy-index.
    it_ObjectID-date =  it_sobid-date.
    flag = 'y'.
    endloop.
    you can write some logic like this. Its just a rough idea you can modify according to ur need.
    Regards,
    Ravi

  • Desperate need of HELP for a Java GUI !

    Hy people,
    I am working on a project trying to display a GUI where its output is dependant on the user's input.
    Here is a brief example of what Im trying to do:
    You have a GUI that contains 2 panels. buttonPanel and DisplayPanel.
    buttonPanel contains:
    a dropdown list: includes choices of colors,
    2 textfields: the length: (can enter from 1 to 100),
    the width: (can enter from 1 to 100),
    a checkbox: random
    and a start button.
    Now when I enter ALL the information needed in the components and then press start button, it should display its result in the DisplayPanel.
    In my case, I want to display just one rectangle to start off. That will have its color changed by the dropdown choice made. Now Im forgetting about the length and width textfield for now cause that will be incorporated for something else later on.
    I created a buttonLitener for the start button and an ItemListener for the dropDown List.
    I declared and drew a rectangle specific to the color chosen by the user in a class I created called DrawingCanvas that extends Canvas and that overrides the paint method.
    BUT My problem is that it does not display the rectangle I created in my DisplayPanel when I press on the Start button.
    I provided a screenshot of the GUI interface, and my 2 java files. Is someone brave enough to fix my problem or even tell me what Im doing wrong ?!
    ScreenShot:
    http://www.hybrid.concordia.ca/~boumbo/GUIProblem.jpg
    Java Files:
    http://www.hybrid.concordia.ca/~boumbo/GUI.zip]Java Files
    PLEASE I am not Amazing with Java, and pulling my hair out in figuring out my problem.
    Thank you.

    Seriously, look at the first reply in the following thread. It gives a pretty good idea of generally accepted good practices in the forum.
    http://forum.java.sun.com/thread.jspa?threadID=603683
    It is probably better to post code directly on the forum than to try to get people to take the extra steps to download, unzip, and compile your code. That way, they can just cut and paste to try to compile. Be sure to use [code][/code] tags to make your code easier to use. And, try to provide a small example of your problem if the code is very long or complex.
    Another piece of advice. Don't try to challenge the regulars in this forum to prove that they are smart enough, brave enough, whatever enough to tackle YOUR problem. The regulars here include software engineers, authors, and generally very smart and experienced people They don't need to prove themselves to anyone.
    What they want to see is that you have genuinely tried to understand your problem, rather than just running to the forum the first time you get a compiler error.
    You seem to have been working on this problem. Go ahead and create a test case that shows what the problem is. Quite frequently, just doing that will help you solve the problem yourself.
    Good luck.
    RD-R
    � {�
    Mon Mar 07 00:57:45 EST 2005
    Pseudo-random saying number 257 of 635
    For every complex problem, there is a solution that is simple, neat,
    and wrong.
                    -- Henry Louis Mencken

  • Need urgently help for OBIEE Installation (11g)

    Hi all,
    I am having problems trying to install Oracle Business Intelligence 11g on Windows 7.
    The Installation Wizard hangs on the step: Domain Configuration (0%). The Creating Domain shows In progress.
    The log under the Inventory directory shows me only following:
    INFO: Ending the inventory Session
    INFO: Using an existing InstallAreaControl for this Inventory Session with existing access level 1
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    INFO: The ORACLE_CONFIG_HOME env var is set to
    I really don't know what to do. I am searching for a solution on Internet, but I don't find it.
    I need urgently help. I would appreciate someone could help me.
    We can do together via Webex or something similar. It doesnt worth it for me to type here and wait till someone give me an answer (if any), trying to find out how I did.
    I hope to find the help I need. I am desperated :-(

    Can I install the OBIEE 10g version?I am not sure but i think OBIEE is not certified with windows 7. i could not find any MOS doc confirming same. Please log a call with oracle to confirm this.
    would it work fine with the Oracle Database 11g and the RCUs?. Yes OBIEE 10g will work with oracle database 11g.
    Thanks,
    JD

  • In serious need of help for huge Premiere Pro Picture glitch. Confounded beyond belief.

    Gents and ladies, I have been at this for two days and am in desperate need of help. Right now my editing in Premiere Pro is completely stalled due to a bizzare picture glitch. I am 100% stuck and unable to edit.
    When I add a picture to my bin, it's ok. Then I add a second and it seems fine. But any and all pictures I add after that show up as the first picture. Never mind that the name of the file appears correct.
    The picture itself, both the thumbnail and the picture in the timeline, etc. are just the first picture.
    I have rebooted,restarted, started new projects with new settings, cleared the Premiere Pro cache... NOTHING works.
    Video is not a problem. Only pictures. And I am now dead in the water as a result.
    Look at this screenshot. See how the other than the second picture they are all the same? Well, they shouldn't be. But they are. And I am stuck and unable to edit at all as a result.
    WTH is happening here?
    I have Premiere Pro 5 on a PC from Adobe Production Premium.
    One issue I have had recently is in the middle of editing Premiere Pro will start conforming video that has already been conformed prior.
    Begging for help here.

    I guess I should expect a snarky answer from someone named "Snarky McSnarkster." You are being quite rude. It is not helpful to tell someone to fix a glitch by buying new software. That is not a solution. I could just uninstall and re-install, but I am not going to risk losing all of my current projects if something goes wrong. That is like a thermonuclear option. And spending a grand on new software is insane when I don't need it. The software has been fantastic since I bought it. But glitches happen and so I have been in this forum before and always found a solution via some helpful experts.
    It is also absurd to call me disinterested when I have engaged with everyone here and answered all of their questions. Just because I have tried most of what has been suggested and explained as such does not make me the bad guy.
    As for Ann Bens' question: We have seen this issue in the past and re-save was the solution. Are these images RGB?
    Yes, most are RGB. Some I have tried are CMYK. I have tried jpegs, tiffs, bitmaps, png. I am completely clueless as to how this is happening.
    I am about to try opening Photoshop, opening a bunch of pictures and savings them to a new HD, then starting a brand new project.
    For those who have made suggestions, thank you.

  • Need search help for Profit centre

    Hi all,
    I am struggling to facilitate profit centres in SRM. I am quite close to it. I have done some config changes and could get the profit centre option in web browser under cost assignment. The POs are going through in R/3.
    BUT the searchhelp is not available in the web browser in the next field "Assigned to". There are different search helps available in the program LBBP_PDH_ACCF32 for different account assignment categories but not for profit centre.
    Let me know if there is some search help available somewhere in SRM for profit centre.
    Regards,
    Ravi

    Ravi,
    Hi. Profit centres, like cost centres, doen't exist on SRM as an entity. What the system does for cost centres is it holds a key to which system this exists on (eg the logical system name for R3). When you search for cost centres on the account assignement screen the system runs a search help on the R3 backend.
    My guess is that you would need to configure the system to act the same as with cost centres and run the search help for profit centres on teh R3 backend.
    Cheers
    Rob

Maybe you are looking for

  • Install Code Check

    Before beginning I'll have set up the hard drive with a 25gb Windows FAT partition on dev/sda3 and 25 GB free space remaining. Creates Linux system with all partitions including /boot in lvm group, and encrypts /home /var and /root NOTE: Grub as inst

  • af:query   component  "Add Fields"  clarification

    Hi, in the advanced mode of <af:query> using the "Add Fields " function , duplicate fields(same search field can be added multiple times) can be added. Is this a bug or a feature. Where can i refer the doc to confirm this . Thanks.

  • How to understand the storage systems?

    How to get more and more or complete understanding of the storage systems like understanding the hardware components involved,best configuration for the hardware,best practices. Is there any book for the storage knowledge for DBA's.

  • Detect Flash using CF8

    I need to detect whether a browser has flash installed and active, and if not I will switch to an alternative set of code. Can anybody tell me how I can test for an active flash installation? (on CF8) Thanks Mark

  • I can't shut the music off my iphone it keeps playing

    I can't shut the music off on my phone even when I go out of the program