How to print this output. (Array)

Hi all. I have two String array:
String[] a = { "a", "b", "c", "d", "e" };
String[] b = { "b", "d" };
I want to print this two array into this output:
Output:
a
bb
c
dd
e
Anybody can help me how to get this output. I have try with a for loop, but it's not working.

try this,
boolean found=false;
for(int i=0; i<a.length;i++)
         found=false;
         for(int j=0;j<b.length;j++)
                 if(a.equals(b[j])
found=true;
if(found==true)
System.out.println(a[i]+a[i]);
else
System.out.println(a[i]);

Similar Messages

  • Re : how to print report output in DOT MATRIX printer

    Hai
           how to print report output in DOT MATRIX printer.
    Thanks
    mani

    Check this
    [http://help.sap.com/saphelp_nw04/helpdata/en/90/78f078030211d399b90000e83dd9fc/frameset.htm]
    also check the SAP Note 129581

  • How to print this date format: eg. 14-Aug-2002 01:26:36 PM?

    Can anyone tell me exactly how to print this format?

    This is how we can produce the output you specified.
    import java.util.*;
    import java.text.*;
    //14-Aug-2002 01:26:36 PM?
    class Test
         public static void main(String args[])
              //Date b=new Date();
              //System.out.println(b.toString());
              // Format the current time.
              SimpleDateFormat formatter = new SimpleDateFormat ("dd-MMM-yyyy ' ' hh:mm:ss a");
              Date currentTime_1 = new Date();
              String dateString = formatter.format(currentTime_1);
              System.out.println(dateString);
    }//end of Test.

  • How to print the output of the screen in Dialog Programming

    Hi,
    Could anybody help how to print the output of a screen in the dialog programming. i can select 'Hard Copy' option in the 'Custumizing of Local Layout' Icon in the standard tool bar. but that prints the whole screen with the toolbar. i want to print only the output which is displayed on the screen. Please help..
    Regards,
    Swathi

    Hi Swathi,
        Ok. Do One thing. Go to menu bar and select Systems -> Own pool Request -> here you get the spool number. Select it and select the option "Print Directly" in tool bar.
    Thanks.

  • How to get this output using sql query?

    Hi,
      How to get this output using sql query?
    Sno Name Age ADD Result
    1 Anil 23 delhi Pass
    2 Shruti 25 bangalor Pass
    3 Arun 21 delhi fail
    4 Sonu 23 pune Pass
    5 Roji 26 hydrabad fail
    6 Anil 28 delhi pass
    Output
    Sno Name Age ADD Result
    1 Anil 23 delhi pass
    28 delhi pass

    Hi Vamshi,
    Your query is not pretty clear.
    write the select query using Name = 'ANIL' in where condition and display the ouput using Control-break statements.
    Regards,
    Kannan

  • How to acheive this output during the XML conversion ?.

    I am converting the data into XML. I am using Oracle8i.
    create table emp(empno number,
    ename varchar2(20),
    deptno number);
    insert into emp values(101,'Krish',10);
    insert into emp values(102,null, 10);
    insert into emp values(103,'Scott',20);
    commit;
    CREATE OR REPLACE PROCEDURE STP_TEST_XML AS
    v_context DBMS_XMLQUERY.CTXTYPE;
    v_document CLOB;
    v_error_code VARCHAR2(3) := 'OK';
    BEGIN
    v_context:= DBMS_XMLQUERY.NEWCONTEXT('SELECT * FROM EMP');
    DBMS_XMLQUERY.USENULLATTRIBUTEINDICATOR(v_context,TRUE);
    DBMS_XMLQUERY.SETROWSETTAG(v_context,'EMPIMPORT');
    DBMS_XMLQUERY.SETROWTAG(v_context,'EMP');
    v_document := DBMS_XMLQUERY.GETXML(v_context);
    DBMS_XMLQUERY.CLOSECONTEXT(V_context);
    PRINT_XML(v_document);
    END;
    CREATE OR REPLACE PROCEDURE print_xml(result IN OUT NOCOPY CLOB) is
    xmlstr varchar2(32767);
    line varchar2(2000);
    begin
    xmlstr := dbms_lob.SUBSTR(result,32767);
    loop
    exit when xmlstr is null;
    line := substr(xmlstr,1,instr(xmlstr,chr(10))-1);
    dbms_output.put_line('| '||line);
    xmlstr := substr(xmlstr,instr(xmlstr,chr(10))+1);
    end loop;
    end;
    The output is showing as below.
    <?xml version = '1.0'?>
    <EMPIMPORT>
    <EMP num="1">
    <EMPNO>101</EMPNO>
    <ENAME>Krish</ENAME>
    <DEPTNO>10</DEPTNO>
    </EMP>
    <EMP num="2">
    <EMPNO>102</EMPNO>
    <ENAME NULL="YES"/>
    <DEPTNO>10</DEPTNO>
    </EMP>
    <EMP num="3">
    <EMPNO>103</EMPNO>
    <ENAME>Scott</ENAME>
    <DEPTNO>20</DEPTNO>
    </EMP>
    </EMPIMPORT>
    But my requirement needs my output should be as below. Please let me know how to achieve this output.
    <?xml version = '1.0'?>
    <EMPIMPORT>
    <EMP num="1">
    <EMPNO>101</EMPNO>
    <ENAME>Krish</ENAME>
    <DEPTNO>10</DEPTNO>
    </EMP>
    <EMP num="2">
    <EMPNO>102</EMPNO>
    <ENAME/>
    <DEPTNO>10</DEPTNO>
    </EMP>
    <EMP num="3">
    <EMPNO>103</EMPNO>
    <ENAME>Scott</ENAME>
    <DEPTNO>20</DEPTNO>
    </EMP>
    </EMPIMPORT>

    can you please tell me how to acheive 1,2,3  instead of the chars.
    Also if I use virtual characteristic can I able to access the query structure in the user exit like the restricted key figures etc or just the records how they appear in the cube.
    Thank you guys for the quick response.

  • Tutorial on how to print  multiple output pages

    Hi,
    I am rather sad that this forum does not provide a simple principle on how to printout multiple pages to newbie.
    Below is a short contribution from me on how to print across multiple pages, other reader are also encourage to modify the code to provide more robust tutorial .
    * How to use java to print across pages that are more than one
    * Short contribution to java forum by Eric gan (Malaysia)
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.print.*;
    import java.awt.Graphics2D;
    import java.awt.print.*;
    import java.awt.print.Book;
    import java.awt.print.Pageable;
    import java.awt.Graphics2D;
    import java.awt.Graphics;
    public class Example implements Printable {
    //--- Private instances declarations
    private int row_cnt=30; // set the total number of row per page
    private int cum_row_cnt=30; // set the counter to record total number of row per page to determine
    // whether maximum pages should be increase depending on the programme requirement
    private int max_pg=0; // set the maximum number of page
    public Example () {
    //--- Create a printerJob object
    PrinterJob printJob = PrinterJob.getPrinterJob ();
         printJob.setPrintable(Example.this);
    if (printJob.printDialog()) {
    try {
    printJob.print();
    } catch (Exception PrintException) {
    PrintException.printStackTrace();
    public void paint (Graphics g) {
    Graphics2D g2d;
    g2d = (Graphics2D) g;     
    int x=10;
    int y=10;
    for (int outline=0;outline<=160;outline+=20){
              if (y>cum_row_cnt){
              cum_row_cnt+=row_cnt;//counter should grow by value equal to row_cnt
         max_pg++;
         g2d.drawString("outline value ---> " +outline , x, y);
         y+=10; // to set the row printing interval      
    } // end of paint procedure
         public int print(Graphics g,
    PageFormat pf, int pi)
              throws PrinterException {
    // normal routine to check when should java stop the print looping
    if (pi >max_pg) {
    return Printable.NO_SUCH_PAGE;
    Graphics2D g2 = (Graphics2D) g;
         int fontHeight=g2.getFontMetrics().getHeight();
         int fontDesent=g2.getFontMetrics().getDescent();
         double pageHeight = pf.getImageableHeight()-fontHeight;
         double pageWidth = pf.getImageableWidth();
         // setting for the translate and graphics clipping to enable printing on output pages
    // row_cnt can be equal to pageHeight
    // in this examples assumming pageHeight=20 rows           
         g2.translate(pf.getImageableX(), pf.getImageableY());
    g2.translate(0f,-pi*row_cnt);
    g2.setClip(0, (int)(row_cnt* pi),
    (int) Math.ceil(pageWidth),
    (int) Math.ceil(row_cnt));
    paint(g2);
    return Printable.PAGE_EXISTS;
    public static void main (String [] args) {
    Example example = new Example ();
    System.exit (0);
    Thank

    Hello
    I know that Pages is using its own algorithm to resize pages when it put several of them on a single sheet.
    This is why I use this tip.
    I draw a rectangle whose size is supposed to be the final one.
    I give it a white background and a black border whose thickness is set to one point.
    For the tests I just insert three page breaks so that the document is a four pages one.
    I print it as is.
    Doing that, I may measure the printed rectangle.
    Of course, at first attempt it doesn't match the required size.
    It's easy to compute the required adjustments.
    When the correct factor is reached, it is easy to build the complete document so that it prints the correct size.
    Doing that I never got odd results but maybe it's because I am a lucky guy.
    Of course, disagreeing with one advice doesn't mean that I don't respect it.
    I respect your opinion, _on other matters too_
    Yvan KOENIG (from FRANCE mardi 6 mai 2008 17:24:09)

  • How to print an output stream on console.

    Hi,
    I am new to JAVA. I am trying to execute a command in runtime and I want to print the output on console and also redirect the output to a file.
    Could anyone please help me?
    This is what I wrote :
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec("cmd /c ipconfig");I am getting an output stream by : proc.getOutputStream(). I dont know how to print it on console and also how to redirect it to a file.
    Could anyone please help me.
    Thanks in advance.
    Basav

    You can do it this way :-
         public static void main(String args[]) throws Exception {
              ProcessBuilder builder = new ProcessBuilder("ipconfig", "/all");
              Process process = builder.start();
              BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
              FileWriter writer = new FileWriter(new File("C:/ipconfig.txt"));
              String str;
              while ((str = reader.readLine()) != null) {
                   System.out.println(str);
                   writer.write(str + System.getProperty("line.separator"));
              writer.close();
              reader.close();
         }Let me know if it works for you.

  • How to loop an output array and pass each index to the next VI in the sequence in TestSTAND?

    Hi,
    I have 2 VIs - XX and YY. The output of XX generates an array of strings.
    The input of YY takes in a string. I have VIs XX followed by YY in the
    sequence editor.
    For each item in the output array of XX, I want to pass that item into
    YY and execute YY.
    How do I do this in TestStand without creating an intermediate VI.
    Your help is greatly appreciated folks!
    Thx

    Hi,
    What you could do is set the second step to loop.
    Then use as one of the parameters to VI YY the string array using RunState.LoopIndex as the array index.
    eg. Locals.MyStringArray[RunState.LoopIndex]
    Hope this helps
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • How to generate this output?URGENT

    how to generate using DOM or SAX to get this output?
    <project>
    <process name = " Process1 " >
    </project>
    i am stuck here ... may i know how to continued coding from here.. must add in wat ? can any one tell me thank....
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.*;
    import org.w3c.dom.DOMException;
    import java.io.*;
    import java.util.*;
    public class TestVector
         private Vector m_vProcess;
         String strProjectName;
         public static void main(String[] args)
              TestVector pThis = new TestVector();
              pThis -> WriteToXML(m_vProcess);
         public void TestVector {
              strProjectName ="Project1";
              m_vProcess = new Vector();               
              m_vProcess.add("Process1");
              m_vProcess.add("Process2");
         public void WriteToXML(Vector vProcess)
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              DocumentBuilder builder = facory.newDocumentBuilder();
              Document builder = builder.parse("Project.xml");
              Node rootNode = document.getDocumentElement();
              NodeList list = document.getElementsByTagName("Project");
    // Loop through the list.
              for (int i=0; i < list.getLength(); i++) {
              thisProjectNode = list.item(i);
              Node thisName1Node = thisProjectNode.getFirstChild();
              if (thisName1Node == null) continue;
              if (thisName1Node.getFirstChild() == null) continue;
              if (! thisName1Node.getFirstChild() instanceof
    org.w3c.dom.Text) continue;
              String data = thisName1Node.getFirstChild().getNodeValue();
              if (! data.equals("Process1")) continue;
    //We're at the Mocha Java node. Create and insert the new
    //element.
              Node newCoffeeNode = document.createElement("Project");
              Node newName1Node = document.createElement("Process");
              Text tnNode = document.createTextNode("Process1");
              newName1Node.appendChild(tnNode);
              Node newName2Node = document.createElement("Process");
              Text tpNode = document.createTextNode("Process2");
              newName2Node.appendChild(tpNode);
              newProjectNode.appendChild(newName1Node);
              newProjectNode.appendChild(newName2Node);
              rootNode.insertBefore(newProjectNode, thisProjectNode);
              break;

    i am not good in programming..wat ever i read b4 ,i wlll forget easily ..and y the output nv come out after i type these...
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.*;
    import org.w3c.dom.DOMException;
    import java.io.*;
    import java.util.*;
    public class TestVector
         private Vector m_vProcess;
         String strProjectName;
         public static void main(String[] args)
              TestVector pThis = new TestVector();
              pThis -> WriteToXML(m_vProcess);
         public void TestVector {
              strProjectName ="Project1";
              m_vProcess = new Vector();               
              m_vProcess.add("Process1");
              m_vProcess.add("Process2");
         public void WriteToXML(Vector vProcess)
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              DocumentBuilder builder = facory.newDocumentBuilder();
              Document builder = builder.parse("Project.xml");
              TransformerFactory tfac = TransformerFactory.newInstance();
              FileWriter fileWtr = new FileWriter("output.xml");
              StreamResult strResult = new StreamResult(fileWtr);
              Transformer trans = tfac.newTransformer();
              trans.transform(new DOMSource(document.getDocumentElement()),strResult);
              Node rootNode = document.getDocumentElement();
              NodeList list = document.getElementsByTagName("Project");
    // Loop through the list.
              for (int i=0; i < list.getLength(); i++) {
              thisProjectNode = list.item(i);
              Node thisName1Node = thisProjectNode.getFirstChild();
              if (thisName1Node == null) continue;
              if (thisName1Node.getFirstChild() == null) continue;
              if (! thisName1Node.getFirstChild() instanceof
    org.w3c.dom.Text) continue;
              String data = thisName1Node.getFirstChild().getNodeValue();
              if (! data.equals("Process1")) continue;
              Node newCoffeeNode = document.createElement("Project");
              Node newName1Node = document.createElement("Process");
              Text tnNode = document.createTextNode("Process1");
              newName1Node.appendChild(tnNode);
              Node newName2Node = document.createElement("Process");
              Text tpNode = document.createTextNode("Process2");
              newName2Node.appendChild(tpNode);
              newProjectNode.appendChild(newName1Node);
              newProjectNode.appendChild(newName2Node);
              rootNode.insertBefore(newProjectNode, thisProjectNode);
              break;

  • How to take this output from javacreator?

    i wanna take this output.
    123456
    12345
    1234
    123
    12
    1

    ... What? Can you word that into a somewhat sensible English sentence? Are you trying to create that output? I assume javacreator = JCreator? Anyways... I would suggest starting with a for loop nested within another for loop. That would be your best bet in terms of difficulty to implement.
    Hint: first for loop would be your max number, going down, nested loop should be for printing each line.
    Edited by: XTTX on Nov 25, 2007 5:52 AM

  • One for the Tekkies: How to get this output using REGULAR EXPRESSIONS?

    How to get the below output using REGULAR EXPRESSIONS??
    SQL> ed
    Wrote file afiedt.buf
      1* CREATE TABLE cus___addresses    (full_address                   VARCHAR2(200 BYTE))
    SQL> /
    Table created.
    SQL> PROMPT Address Format is: House #/Housename,  street,  City, Zip Code, COUNTRY
    House #/Housename,  street,  City, Zip Code, COUNTRY
    SQL> INSERT INTO cus___addresses VALUES('1, 3rd street, Lansing, MI 49001, USA');
    1 row created.
    SQL> INSERT INTO cus___addresses VALUES('3B, fifth street, Clinton, OK 74103, USA');
    1 row created.
    SQL> INSERT INTO cus___addresses VALUES('Rose Villa, Stanton Grove, Murray, TN 37183, USA');
    1 row created.
    SQL> SELECT * FROM cus___addresses;
    FULL_ADDRESS
    1, 3rd street, Lansing, MI 49001, USA
    3B, fifth street, Clinton, OK 74103, USA
    Rose Villa, Stanton Grove, Murray, TN 37183, USA
    SQL> The REG EXP query shouLd output the ZIP codes: i.e. 49001, 74103, 37183 in 3 rows.Edited by: user12240205 on Jun 18, 2012 3:19 AM

    Hi,
    user12240205 wrote:
    ... Frank, ʃʃp's method, I understand. But your method, although correct, I find it difficult to understand.
    Could you explain how you did this?? What does '.*(\d{5})\D*' and '\1' mean???
    Your method is better because it uses only ONE reg expression function. ʃʃp's uses 2.In Oracle 10.2 (I believe) and higher, '\d' is equivalent to '[[:digit:]]', and '\D' is equivalent to '[^[:digit:]]'. I find '\d' and '\D' easier to type, but there's nothing wrong with using '[[:digit:]]' and '[^[:digit:]]'.
    '.*' means "0 or more of any character".
    '\D*' means "0 or more non-digits".
    The whole expression, '.*(\d{5})\D*' means:
    a. 0 or more characters (any characters)
    b. 5 digits
    c. 0 or more non-digits.
    '\1' is a Backreference . It means the sub-string that matched the pattern after the 1st '(', up to (but not including) its matching ')'. In this case, that means the sub-string that matched '\d{5}', or b. using the explanation immediately above.
    So the entire REGEXP_REPLACE call means "When you see a sub-string consisting of a., follwed immediately by b., followed immedately by c., replace that sub-string with b. alone."

  • How to print this?

    i need help. if someone could tell me how to print the following pattern
    thank you

    Try having below code snippet in ur program.
    int i=1;
    for(;i<5;i++)
    for(int j=1;j<=i;j++)
    System.out.print("*");
    System.out.print("\n");
    Regs
    Jounty

  • How to print console output

    Hi, I have a JSP page and I would like to print STDOUT to the page. Is this possible?
    I've seen a few methods and none work for me:
    BufferedReader reader = new BufferedReader(System.out);
    String input = reader.readLine();
    out.println(input);*** Error: Type BufferedReader was not found.
    FileOutputStream out;
                    PrintStream ps; // declare a print stream object
                    try {
                     // Create a new file output stream
                    out = new FileOutputStream("myfile.txt");
                            // Connect print stream to the output stream
                            ps = new PrintStream(out);
                            ps.println ("This data is written to a file:");
                System.err.println ("Write successfully");
                            ps.close();
                    catch (Exception e){
                            System.err.println ("Error in writing to file");
                    }*** Error: Duplicate declaration of local variable "out".
    *** Error: The type of the left-hand side in this assignment, "javax/servlet/jsp/JspWriter", is not compatible with the type of the right-hand side expression, "java/io/FileOutputStream".
    *** Error: No match was found for constructor "PrintStream(javax.servlet.jsp.JspWriter)".
    So what's next?
    How can I call the console without writing to a file first?
    I would like AJAX to show console output in real-time.

    Thanks for your help.
    The reason I have the script to write to a file is because it's the closest I could find to what I want. Ideally, I would be able to run a script that prints to the console but I want to grab the system.out going to the console and display it on the page.
    Basically, I want the page to act as a console but not redirect the output (I want it to still go to the console) and I don't want it in a text file that the page reads.
    So for example, the page loads and while that is occurring, the server grabs the console output and prints to the page. Then I run a function on the page that prints to the console and on the refresh, print the updated output. Ideally, I would restrict the output that was relevant to the page's functions and ignore every output to the console but I'm not (trying to be) picky.
    So how would that work?
    Pseudo-code:
    for (int i=0;i < System.out().length(); i++) {
            String grabbedtext += System.out().toString();
    }out.println(grabbedtext);

  • How to get this output format in ALV report

    Hi.
    Can any one pls let me know how to get the following output format in ALV report.Following are the outputfields
    companycode   location     position     approver
    300    800       01    watson
    null   null        03     candy
    null   null        04     smith
    null   null        05     michael
    one empty line after this again
    300     800     01     ryant
    null      null    02     gyan
    null      null    03     fermi
    null      null    04     ogata
    *Note: Null     indicates  empty space .( i.e I need to get empty space in  output where ever null is there.)
            Thanks in advance.
    Kind Regards,
    samiulla.

    hi,
    u can use 'REUSE_ALV_LIST_DISPLAY'
                           or
    'REUSE_ALV_GRID_DISPLAY'  function modules.
    SAMPLE CODE :
    *& Report  Y101982CHD
    *                         TABLES
    TABLES: vbak.    " standard table
    *                           Type Pools                                 *
    TYPE-POOLS: slis.
    *                     Global Structure Definitions                     *
    *-- Structure to hold data from table CE1MCK2
    TYPES: BEGIN OF tp_itab1,
           vbeln LIKE vbap-vbeln,
           posnr LIKE vbap-posnr,
           werks LIKE vbap-werks,
           lgort LIKE vbap-lgort,
           END OF tp_itab1.
    *-- Data Declaration
    DATA: t_itab1 TYPE TABLE OF tp_itab1.
    DATA : i_fieldcat TYPE slis_t_fieldcat_alv.
    *                    Selection  Screen                                 *
    *--Sales document-block
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
    SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.
    SELECTION-SCREEN END OF  BLOCK b1.
    *--Display option - block
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02.
    PARAMETERS: alv_list RADIOBUTTON GROUP g1,
                alv_grid RADIOBUTTON GROUP g1.
    SELECTION-SCREEN END OF  BLOCK b2.
    *file download - block
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t03.
    PARAMETERS: topc AS CHECKBOX,
                p_file TYPE rlgrap-filename.
    SELECTION-SCREEN END OF  BLOCK b3.
    *                      Initialization.                                *
    *                      At Selection Screen                            *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
        EXPORTING
          dynpfield_filename = 'P_FILE'
          dyname             = sy-cprog
          dynumb             = sy-dynnr
          filetype           = 'P'      "P-->Physical
          location           = 'P'     "P Presentation Srever
          server             = space.
    AT SELECTION-SCREEN ON s_vbeln.
      PERFORM vbeln_validate.
    *                           Start Of Selection                         *
    START-OF-SELECTION.
    *-- Fetching all the required data into the internal table
      PERFORM select_data.
    *                           End Of Selection                           *
    END-OF-SELECTION.
      IF t_itab1[] IS NOT INITIAL.
        IF topc IS NOT INITIAL.
          PERFORM download.
          MESSAGE 'Data Download Completed' TYPE 'S'.
        ENDIF.
        PERFORM display.
      ELSE.
        MESSAGE 'No Records Found' TYPE 'I'.
      ENDIF.
    *                           Top Of Page Event                          *
    TOP-OF-PAGE.
    *& Form           :      select_data
    * Description     : Fetching all the data into the internal tables
    *  parameters    :  none
    FORM select_data .
      SELECT vbeln
         posnr
         werks
         lgort
         INTO CORRESPONDING  FIELDS OF TABLE t_itab1
         FROM vbap
         WHERE  vbeln IN s_vbeln.
      IF sy-subrc <> 0.
        MESSAGE 'Enter The Valid Sales Document Number'(t04) TYPE 'I'.
        EXIT.
      ENDIF.
    ENDFORM.                    " select_data
    *& Form        : display
    *  decription  : to display data in given format
    * parameters   :  none
    FORM display .
      IF alv_list = 'X'.
        PERFORM build_fieldcat TABLES i_fieldcat[]
                               USING :
    *-Output-field Table      Len  Ref fld Ref tab Heading    Col_pos
       'VBELN'       'T_ITAB1'     10   'VBAP'  'VBELN'    ''            1,
       'POSNR'       'T_ITAB1'     6    'VBAP'  'POSNR'    ''            2,
       'WERKS'       'T_ITAB1'     4    'VBAP'  'WERKS'    ''            3,
       'LGORT'       'T_ITAB1'     4    'VBAP'  'LGORT'    ''            4.
        *CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'*
          *EXPORTING*
            *i_callback_program       = sy-repid*
    **        i_callback_pf_status_set = c_pf_status*
            *i_callback_user_command  = 'USER_COMMAND '*
    **        it_events                = t_alv_events[]*
            *it_fieldcat              = i_fieldcat[]*
          *TABLES*
            *t_outtab                 = t_itab1[]*
          *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.*
      ENDIF.
      IF alv_grid = 'X'.
        PERFORM build_fieldcat TABLES i_fieldcat[]
                                 USING :
    *-Output-field Table      Len  Ref fld Ref tab Heading    Col_pos
         'VBELN'       'T_ITAB1'     10   'VBAP'  'VBELN'    ''            1,
         'POSNR'       'T_ITAB1'     6    'VBAP'  'POSNR'    ''            2,
         'WERKS'       'T_ITAB1'     4    'VBAP'  'WERKS'    ''            3,
         'LGORT'       'T_ITAB1'     4    'VBAP'  'LGORT'    ''            4.
        *CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'*
          *EXPORTING*
            *i_callback_program       = sy-repid*
    **        i_callback_pf_status_set = c_pf_status*
            *i_callback_user_command  = 'USER_COMMAND '*
            *it_fieldcat              = i_fieldcat*
          *TABLES*
            *t_outtab                 = t_itab1[]*
        *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.*
      *ENDIF.*
    ENDFORM.                    " display
    *& Form        : vbeln_validate
    *  description : to validate sales document number
    * parameters   :  none
    FORM vbeln_validate .
      DATA: l_vbeln TYPE vbak-vbeln.
      SELECT SINGLE vbeln
        FROM vbak
        INTO l_vbeln
        WHERE vbeln IN s_vbeln.
      IF sy-subrc NE 0.
        MESSAGE 'ENTER THE VALID SALES DOCUMENT NO:' TYPE 'I'.
        EXIT.
      ENDIF.
    ENDFORM.                    " vbeln_validate
    *& Form       :build_fieldcat
    * Description : This routine fills field-catalogue
    *  Prameters  : none
    FORM build_fieldcat TABLES  fpt_fieldcat TYPE slis_t_fieldcat_alv
                        USING   fp_field     TYPE slis_fieldname
                                fp_table     TYPE slis_tabname
                                fp_length    TYPE dd03p-outputlen
                                fp_ref_tab   TYPE dd03p-tabname
                                fp_ref_fld   TYPE dd03p-fieldname
                                fp_seltext   TYPE dd03p-scrtext_l
                                fp_col_pos   TYPE sy-cucol.
    *-- Local data declaration
      DATA:   wl_fieldcat TYPE slis_fieldcat_alv.
    *-- Clear WorkArea
      wl_fieldcat-fieldname       = fp_field.
      wl_fieldcat-tabname         = fp_table.
      wl_fieldcat-outputlen       = fp_length.
      wl_fieldcat-ref_tabname     = fp_ref_tab.
      wl_fieldcat-ref_fieldname   = fp_ref_fld.
      wl_fieldcat-seltext_l       = fp_seltext.
      wl_fieldcat-col_pos         = fp_col_pos.
    *-- Update Field Catalog Table
      APPEND wl_fieldcat  TO  fpt_fieldcat.
    ENDFORM.                    "build_fieldcat
    *& Form        : download
    *  description : To Download The Data
    *  Parameters  :  none
    FORM download .
      DATA: l_file TYPE string.
      l_file = p_file.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = l_file
          filetype                = 'ASC'
        TABLES
          data_tab                = t_itab1
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6.
      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.                    " download
    HOPE IT WILL HELP YOU
    REGARDS
    RAHUL SHARMA

Maybe you are looking for

  • OSA Appraisal- additional header data in BSP

    Hi, I implemented the badi HRHAP00_ADD_HEADER to display additional date for the appraisee. The additional data are correctly displayed in the SAP GUI with the standard transaction phap_change. However, if I use the standard BSPs (via ../sap/bc/bsp/s

  • HT5557 Are some iBooks not available to download on the iPhone?

    I use iBooks on my MacBook Pro and iPhone 6, however there are two books that I have purchased in the iBook Store that I am not able to download on my iPhone: The Innovators and Learn to Code in Swift. The Innovators shows up in the Not on This iPhon

  • Why is the youtube app not the new ipad

    why dont i have the youtube app thingy that used to be there

  • Suddenly can't open file

    I have only ever had one version of InDesign on my computer, version CS5.5. Last month I worked on a file with no problem, then today I just went to revise it and I suddenly get the message "Cannot open file because it was saved with a newer version

  • Don't know how to use the swing timer

    Hi there, I did this stupid game for training purposes: There are 3 buttons, 2 of them are "correct", 1 exits the program and you lost. It works so far but when clicking the "wrong" button I thought of changing the frame to red, let the program wait