1) Write A Java Program For Bubble Sort Using Class Concept.
import java.io.*;
class bubble {
void sort(int arr[])
{
int n = arr.length;
for(int i=0; i<n-1; i++)
for(int j=0; j<n-i-1; j++)
if(arr[j] > arr[j+1])
{
int temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
void printArray(int arr[])
{
int n = arr.length;
for(int i=0; i<n; i++)
System.out.println(arr[i]);
}
public static void main (String args[])
{
bubble ob = new bubble();
int arr[] = {64,34,25,12,22,11,90};
ob.sort(arr);
System.out.println("sorted array");
ob.printArray(arr);
}
}
2) Write A Java Program to Illustrate A Binary Search.
import java.io.*;
public class binarysearch
{
int search(int arr[], int l, int r, int x)
{
if(r>=l)
{
int mid = l + (r-1)/2;
if (arr[mid]==x)
return mid;
if(arr[mid] > x)
return search(arr,l,mid-1,x);
else
return search(arr,mid+1,r,x);
}
return-1;
}
public static void main(String args[])
{
binarysearch ob = new binarysearch();
int arr[] = {2,3,4,10,40};
int n = arr.length;
int x = 10;
int result = ob.search(arr,0,n-1,x);
if(result == -1)
System.out.println("element not present");
else
System.out.println("element found at index"+result);
}
}
3) Write A Java Program To Illustrate Constructor Overloading.
import java.io*;
class studentcon
{
int id;
String name;
int age;
studentcon(int i, String n)
{
id = i;
name = n;
}
studentcon(int i, String n, int a)
{
id = i;
name = n;
age = a;
}
void display()
{
System.out.println("------------student info----------");
System.out.println("name of student is="+name);
System.out.println("rno of student="+id);
System.out.println("age of student is="+age);
}
public static void main(String args[])
{
studentcon s1 = new studentcon(301,"karan");
studentcon s2 = new studentcon(801,"smita",19);
s1.display();
s2.display();
}
}
4) Write A Java Program Which Display's No. Of Objects Created By Static Variable.
import java.io.*;
class Countobject
{
static int count;
Countobject()
{
count ++;
}
public static void main(String args[])
{
Countobject ob1 = new Countobject();
Countobject ob2 = new Countobject();
Countobject ob3 = new Countobject();
Countobject ob4 = new Countobject();
Countobject ob5 = new Countobject();
System.out.println("total number of
objects:"+Countobject.count);
}
}
5) Write A Java Program To Count The Frequency Of Words And Characters In Given String.
import java.io*;
class frequency
{
public static void main(String args[])
{
String str = "i am student of gss belgavi cs dept";
int word = 0;
int freq[] = new int[str.length()];
int i,j;
char String[] = str.toCharArray();
for(i=0;i<str.length();i++)
{
if(String[i]==' ')
word = word + 1;
}
System.out.println("no of words are:"+(word+1));
for(i=0;i<str.length();i++)
{
freq[i] = 1;
for(j= i+1;j<str.length();j++)
{
if(String[i] == String[j])
{
freq[i]++;
String[j] = '0';
}
}
}
System.out.println("characters and their corresponding
frequencies");
for(i=0;i<freq.length;i++)
{
if(String[i] !=' '&&String[i] !='0')
System.out.println(String[i] + "-" + freq[i]);
}
}
}
6)Program using interface to determine whether the student is eligible for exam or not.
interface department
{
int att=30;
void getatt();
}
class student
{
String name;
String division;
int rollno;
void getvalue(String n, String c,int r)
{
name=n;
rollno=r;
division=c;
}
void display()
{
System.out.println("name of the student:"+name);
System.out.println("roll no of the student:"+rollno)
System.out.println("division of the student:"+division);
}
}
class exam extends student implements department
{
public void getatt()
{
System.out.println("attendance of student:"+att);
if(att>50)
System.out.println("elligible");
else
System.out.println("not elligible");
}
}
class interfacex
{
public static void main(String args[])
{
exam e= new exam();
e.getvalue("pawan","bsc",808);
e.display();
e.getatt();
}
}
7) Write A Java Program To Implement Exception Handling Using Multiple Catch Statements.
class Multicatch2
{
public static void main(String[] args)
{
try
{
int a,b,c;
a=200;
b=0;
c=a/b;
}
catch(ArithmeticException e)
{
System.out.println(e);
}
catch(NullPointerException e)
{
System.out.println(e);
}
catch(NumberFormatException e)
{
System.out.println(e);
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println(e);
}
System.out.println("welcome to java");
System.out.println("welcome to gss college...");
}
}
8) Write A Java Program To Demonstrate User Defined Package.
Javac -d . a.java
Javac -d . a.java
Javac demo.java
Java demo
9) Illustrate Creation Of Thread By Extending Thread Class.
class multithread1 extends Thread
{
int i;
public void run()
{
for(i=0;i<=5;i++)
{
System.out.println("this is belgavi");
}
}
}
class multithread2 extends Thread
{
int i;
public void run()
{
for(i=0;i<=5;i++)
{
System.out.println("this is karnataka");
}
}
}
class Thrd
{
public static void main(String args[])
{
multithread1 obj1= new multithread1();
multithread2 obj2= new multithread2();
obj1.start();
obj2.start();
}
}
10) Illustrate Thread Creation By Implementing Runnable Interface.
class multithread1 implements Runnable
{
int i;
public void run()
{
for(i=0;i<=5;i++)
{
System.out.println("this is belgavi");
}
}
}
class multithread2 implements Runnable
{
int i;
public void run()
{
for(i=0;i<=5;i++)
{
System.out.println("this is karnataka");
}
}
}
class Thrd
{
public static void main(String args[])
{
Thread t1 = new Thread(new multithread1());
Thread t2 = new Thread(new multithread2());
t1.start();
t2.start();
}
}
nice
ReplyDeleteimport java.awt.*;
ReplyDeleteimport java.awt.event.*;
public class keyListenerExample extends Frame implements KeyListener
{
Label l=new Label("enter text");
TextField t1=new TextField();
keyListenerExample()
{
setSize(400,400);
setLayout(null);
setVisible(true);
l.setBounds(20,20,100,20);
t1.setBounds(50,50,100,100);
add(l);
add(t1);
t1.addKeyListener(this);
}
public void keyPressed(KeyEvent e)
{
l.setText("key pressed");
}
public void keyReleased(KeyEvent e)
{
l.setText("key released");
}
public void keyTyped(KeyEvent e)
{
l.setText("key typed");
}
public static void main(String args[])
{
keyListenerExample w=new keyListenerExample();
}
}
REPORT z_dynamic_internal_table_example.
ReplyDeleteDATA: lt_dynamic_table TYPE REF TO data. " Dynamic internal table reference
DATA: lr_table_descr TYPE REF TO cl_abap_tabledescr, " Table description reference
lr_struct_descr TYPE REF TO cl_abap_structdescr, " Structure description reference
lt_field_catalog TYPE lvc_t_fcat, " Field catalog for ALV display
lt_data TYPE STANDARD TABLE OF any, " Data table
ls_data TYPE any. " Structure for data row
FIELD-SYMBOLS: TYPE ANY TABLE. " Field symbol for dynamic internal table
* Define the field catalog for ALV display
lt_field_catalog = VALUE #( (fieldname = 'COL1' inttype = 'C' outputlen = 10)
(fieldname = 'COL2' inttype = 'C' outputlen = 20) ).
* Create the dynamic internal table and structure
CREATE DATA lt_dynamic_table TYPE TABLE OF (lt_field_catalog).
lr_table_descr ?= cl_abap_tabledescr=>describe_by_data( lt_dynamic_table ).
lr_struct_descr ?= lr_table_descr->get_table_line_type( ).
* Assign the dynamic table to a field symbol
ASSIGN lt_dynamic_table->* TO .
* Populate the dynamic internal table
ls_data-col1 = 'Value 1'.
ls_data-col2 = 'Value 2'.
APPEND ls_data TO .
ls_data-col1 = 'Value 3'.
ls_data-col2 = 'Value 4'.
APPEND ls_data TO .
* Display the dynamic internal table using ALV grid
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = abap_false
IMPORTING
r_salv_table = DATA(lr_salv_table)
CHANGING
t_table = .
lr_salv_table->get_model( )->set_data( ).
lr_salv_table->display( ).
REPORT z_dynamic_internal_table_example.
ReplyDeleteDATA: lt_dynamic_table TYPE REF TO data. " Dynamic internal table reference
DATA: lr_table_descr TYPE REF TO cl_abap_tabledescr, " Table description reference
lr_struct_descr TYPE REF TO cl_abap_structdescr, " Structure description reference
lt_field_catalog TYPE STANDARD TABLE OF lvc_s_fcat, " Field catalog for display
lt_data TYPE STANDARD TABLE OF lvc_t_styl, " Data for display
ls_field_catalog TYPE lvc_s_fcat, " Field catalog structure
ls_data TYPE lvc_s_styl. " Data structure
FIELD-SYMBOLS: TYPE ANY TABLE, " Dynamic internal table field symbol
TYPE any. " Dynamic internal table line field symbol
* Define the structure of the dynamic internal table
lr_struct_descr = cl_abap_typedescr=>describe_by_name( 'SFLIGHT' ).
lr_table_descr = cl_abap_tabledescr=>create( p_line_type = lr_struct_descr ).
CREATE DATA lt_dynamic_table TYPE HANDLE lr_table_descr.
ASSIGN lt_dynamic_table->* TO .
* Add fields to the field catalog for display
ls_field_catalog-fieldname = 'CARRID'.
ls_field_catalog-seltext_l = 'Carrier ID'.
APPEND ls_field_catalog TO lt_field_catalog.
ls_field_catalog-fieldname = 'CONNID'.
ls_field_catalog-seltext_l = 'Connection ID'.
APPEND ls_field_catalog TO lt_field_catalog.
* Add data to the dynamic internal table
SELECT carrid connid FROM sflight INTO TABLE .
* Display the dynamic internal table using ALV
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = lt_field_catalog
TABLES
t_outtab = .
DATA: lt_data TYPE TABLE OF z_custom_data, " Internal table for custom data
ReplyDeletels_data TYPE z_custom_data. " Structure for each row of custom data
* Populate the internal table with custom data
ls_data-field1 = 'Value 1'.
ls_data-field2 = 'Value 2'.
APPEND ls_data TO lt_data.
ls_data-field1 = 'Value 3'.
ls_data-field2 = 'Value 4'.
APPEND ls_data TO lt_data.
* Display the internal table using ALV grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
TABLES
t_outtab = lt_data.
TYPES: BEGIN OF zmy_data,
ReplyDeletefield1 TYPE string,
field2 TYPE string,
END OF zmy_data.
DATA: lt_data TYPE TABLE OF zmy_data, " Internal table for custom data
ls_data TYPE zmy_data. " Structure for each row of custom data
* Populate the internal table with custom data
ls_data-field1 = 'Value 1'.
ls_data-field2 = 'Value 2'.
APPEND ls_data TO lt_data.
ls_data-field1 = 'Value 3'.
ls_data-field2 = 'Value 4'.
APPEND ls_data TO lt_data.
* Print the data in the internal table
LOOP AT lt_data INTO ls_data.
WRITE: / 'Field 1:', ls_data-field1,
/ 'Field 2:', ls_data-field2.
ENDLOOP.
TYPES: BEGIN OF ty_data,
ReplyDeletecol_no TYPE i,
row_no TYPE i,
text TYPE string,
END OF ty_data.
DATA: lt_data TYPE TABLE OF ty_data,
lt_fieldcat TYPE lvc_t_fcat,
ls_fieldcat TYPE lvc_s_fcat.
APPEND VALUE #( col_no = 1 row_no = 1 text = '0606' ) TO lt_data.
APPEND VALUE #( col_no = 1 row_no = 2 text = '0606' ) TO lt_data.
APPEND VALUE #( col_no = 1 row_no = 3 text = '0606' ) TO lt_data.
...
ls_fieldcat-fieldname = 'COL_NO'.
ls_fieldcat-seltext_m = 'Column'.
APPEND ls_fieldcat TO lt_fieldcat.
ls_fieldcat-fieldname = 'ROW_NO'.
ls_fieldcat-seltext_m = 'Row'.
APPEND ls_fieldcat TO lt_fieldcat.
ls_fieldcat-fieldname = 'TEXT'.
ls_fieldcat-seltext_m = 'Text'.
APPEND ls_fieldcat TO lt_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
TABLES
t_outtab = lt_data
t_fieldcat = lt_fieldcat.
REPORT z_alv_display_example.
ReplyDeleteTYPES: BEGIN OF ty_data,
col_no TYPE i,
row_no TYPE i,
text TYPE string,
END OF ty_data.
DATA: lt_data TYPE TABLE OF ty_data,
lt_fieldcat TYPE lvc_t_fcat[] ,
ls_fieldcat TYPE lvc_s_fcat.
APPEND VALUE #( fieldname = 'COL_NO' seltext_m = 'Column' ) TO lt_fieldcat.
APPEND VALUE #( fieldname = 'ROW_NO' seltext_m = 'Row' ) TO lt_fieldcat.
APPEND VALUE #( fieldname = 'TEXT' seltext_m = 'Text' ) TO lt_fieldcat.
APPEND VALUE #( col_no = 1 row_no = 1 text = '0606' ) TO lt_data.
APPEND VALUE #( col_no = 1 row_no = 2 text = '0606' ) TO lt_data.
APPEND VALUE #( col_no = 1 row_no = 3 text = '0606' ) TO lt_data.
...
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
TABLES
t_outtab = lt_data
t_fieldcat = lt_fieldcat.
REPORT z_alv_display_example.
ReplyDeleteTYPES: BEGIN OF ty_data,
col_no TYPE i,
row_no TYPE i,
text TYPE string,
END OF ty_data.
DATA: lt_data TYPE TABLE OF ty_data,
lt_fieldcat TYPE lvc_t_fcat,
ls_fieldcat TYPE lvc_s_fcat.
APPEND VALUE #( fieldname = 'COL_NO' seltext_m = 'Column' ) TO lt_fieldcat.
APPEND VALUE #( fieldname = 'ROW_NO' seltext_m = 'Row' ) TO lt_fieldcat.
APPEND VALUE #( fieldname = 'TEXT' seltext_m = 'Text' ) TO lt_fieldcat.
APPEND VALUE #( col_no = 1 row_no = 1 text = '0606' ) TO lt_data.
APPEND VALUE #( col_no = 1 row_no = 2 text = '0606' ) TO lt_data.
APPEND VALUE #( col_no = 1 row_no = 3 text = '0606' ) TO lt_data.
...
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
TABLES
t_outtab = lt_data
fieldcat = lt_fieldcat.
REPORT z_alv_display_example.
ReplyDeleteTYPES: BEGIN OF ty_data,
col_no TYPE i,
row_no TYPE i,
text TYPE string,
END OF ty_data.
DATA: lt_data TYPE TABLE OF ty_data,
lt_fieldcat TYPE lvc_t_fcat,
ls_fieldcat TYPE lvc_s_fcat.
APPEND VALUE #( fieldname = 'COL_NO' seltext_m = 'Column' ) TO lt_fieldcat.
APPEND VALUE #( fieldname = 'ROW_NO' seltext_m = 'Row' ) TO lt_fieldcat.
APPEND VALUE #( fieldname = 'TEXT' seltext_m = 'Text' ) TO lt_fieldcat.
APPEND VALUE #( col_no = 1 row_no = 1 text = '0606' ) TO lt_data.
APPEND VALUE #( col_no = 1 row_no = 2 text = '0606' ) TO lt_data.
APPEND VALUE #( col_no = 1 row_no = 3 text = '0606' ) TO lt_data.
...
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
TABLES
t_outtab = lt_data
i_fieldcat = lt_fieldcat.
REPORT z_alv_display_example.
ReplyDeleteTYPES: BEGIN OF ty_data,
col_no TYPE i,
row_no TYPE i,
text TYPE string,
END OF ty_data.
DATA: lt_data TYPE TABLE OF ty_data,
lt_fieldcat TYPE lvc_t_fcat,
ls_fieldcat TYPE lvc_s_fcat.
APPEND VALUE #( fieldname = 'COL_NO' seltext_m = 'Column' ) TO lt_fieldcat.
APPEND VALUE #( fieldname = 'ROW_NO' seltext_m = 'Row' ) TO lt_fieldcat.
APPEND VALUE #( fieldname = 'TEXT' seltext_m = 'Text' ) TO lt_fieldcat.
APPEND VALUE #( col_no = 1 row_no = 1 text = '0606' ) TO lt_data.
APPEND VALUE #( col_no = 1 row_no = 2 text = '0606' ) TO lt_data.
APPEND VALUE #( col_no = 1 row_no = 3 text = '0606' ) TO lt_data.
...
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
TABLES
t_outtab = lt_data
it_fieldcat = lt_fieldcat.
REPORT z_dynamic_internal_table_transpose.
ReplyDeleteTYPES: BEGIN OF ty_row,
col TYPE string,
END OF ty_row.
TYPES: BEGIN OF ty_field,
row TYPE string,
END OF ty_field.
DATA: lt_internal_table TYPE TABLE OF ty_row, " Internal table for original data
lt_transpose_table TYPE TABLE OF ty_field, " Internal table for transposed data
ls_internal_row TYPE ty_row, " Structure for each row in the internal table
ls_transpose_field TYPE ty_field, " Structure for each field in the transposed table
lv_col_count TYPE i, " Column count for transpose
lv_row_count TYPE i. " Row count for transpose
* Populate the internal table with original data
ls_internal_row-col = 'Col1'.
APPEND ls_internal_row TO lt_internal_table.
ls_internal_row-col = 'Col2'.
APPEND ls_internal_row TO lt_internal_table.
ls_internal_row-col = 'Col3'.
APPEND ls_internal_row TO lt_internal_table.
ls_internal_row-col = 'Col4'.
APPEND ls_internal_row TO lt_internal_table.
* Determine the column and row counts for transpose
lv_col_count = 0.
lv_row_count = LINES( lt_internal_table ).
* Create the transpose table dynamically
DO lv_row_count TIMES.
lv_col_count = lv_col_count + 1.
LOOP AT lt_internal_table INTO ls_internal_row INDEX lv_col_count.
ls_transpose_field-row = ls_internal_row-col.
APPEND ls_transpose_field TO lt_transpose_table.
ENDLOOP.
CLEAR: ls_transpose_field.
ENDDO.
* Display the transposed internal table
LOOP AT lt_transpose_table INTO ls_transpose_field.
WRITE: / ls_transpose_field-row.
ENDLOOP.
tables : ekko, ekpo.
ReplyDeletedata : gt_ekko type STANDARD TABLE OF ekko, "po header
gs_ekko type ekko,
gt_ekpo type STANDARD TABLE OF ekpo, "po item
gs_ekpo type ekpo.
"varaibles
data : gv_ebelp type ekpo-ebelp, "for
gv_max_ebelp type ekpo-ebelp. "to select max number of items in data
"for dynamic table
FIELD-SYMBOLS : TYPE STANDARD TABLE, "for dynamic table
,
.
* Create the dynamic internal table
data : NEW_TABLE TYPE REF TO DATA,
NEW_LINE TYPE REF TO DATA.
DATA: FIELDNAME(20) TYPE C,
FIELDVALUE(60) TYPE C.
DATA: IT_FLDCAT TYPE LVC_T_FCAT,
WA_FLDCAT TYPE LVC_S_FCAT,
GS_LAYOUT1 TYPE LVC_S_LAYO. "slis_layout_alv,
SELECTION-SCREEN begin of block b1 WITH FRAME TITLE text-001.
select-OPTIONS : s_ebeln for ekko-ebeln,
s_aedat for ekko-AEDAT,
s_bsart for ekko-bsart.
SELECTION-SCREEN end of BLOCK b1.
START-OF-SELECTION.
perform get_data.
PERFORM BUILD_DYNAMIC_TABLE.
perform build_data.
perform alv_display.
end-of-SELECTION.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
"select header data
select * from ekko into CORRESPONDING FIELDS OF TABLE gt_ekko
WHERE ebeln in s_ebeln
and aedat in s_aedat
and bsart in s_bsart.
"select line item
if gt_ekko[] is NOT INITIAL.
select * from ekpo into CORRESPONDING FIELDS OF TABLE gt_ekpo
FOR ALL ENTRIES IN gt_ekko WHERE ebeln = gt_ekko-ebeln.
sort gt_ekpo DESCENDING by ebelp.
clear : gs_ekpo.
read TABLE gt_ekpo into gs_ekpo INDEX 1.
GV_MAX_EBELP = gs_ekpo-ebelp.
sort gt_ekpo by ebeln ebelp.
endif.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form BUILD_DYNAMIC_TABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_DYNAMIC_TABLE .
CLEAR WA_FLDCAT.
WA_FLDCAT-FIELDNAME = 'EBELN'.
WA_FLDCAT-COLTEXT = 'PO No.'.
WA_FLDCAT-DATATYPE = 'CHAR'.
WA_FLDCAT-OUTPUTLEN = '10'.
WA_FLDCAT-EMPHASIZE = 'C5'.
APPEND WA_FLDCAT TO IT_FLDCAT.
gv_ebelp = 10.
DO.
CLEAR WA_FLDCAT.
ReplyDeleteCONCATENATE GV_EBELP '_MATNR' INTO WA_FLDCAT-FIELDNAME.
CONCATENATE 'Material Code_' gv_ebelp into WA_FLDCAT-COLTEXT.
WA_FLDCAT-DATATYPE = 'CHAR'.
WA_FLDCAT-OUTPUTLEN = '18'.
WA_FLDCAT-NO_ZERO = 'X'.
APPEND WA_FLDCAT TO IT_FLDCAT.
CLEAR WA_FLDCAT.
CONCATENATE GV_EBELP '_TXZ01' INTO WA_FLDCAT-FIELDNAME.
WA_FLDCAT-COLTEXT = 'Description'.
WA_FLDCAT-DATATYPE = 'CHAR'.
WA_FLDCAT-OUTPUTLEN = '40'.
APPEND WA_FLDCAT TO IT_FLDCAT.
CLEAR WA_FLDCAT.
CONCATENATE GV_EBELP '_MENGE' INTO WA_FLDCAT-FIELDNAME.
WA_FLDCAT-COLTEXT = 'Quantity'.
WA_FLDCAT-DATATYPE = 'CURR'.
APPEND WA_FLDCAT TO IT_FLDCAT.
CLEAR WA_FLDCAT.
CONCATENATE GV_EBELP '_NETWR' INTO WA_FLDCAT-FIELDNAME.
WA_FLDCAT-COLTEXT = 'Amount'.
WA_FLDCAT-DATATYPE = 'CURR'.
APPEND WA_FLDCAT TO IT_FLDCAT.
if gv_ebelp = GV_MAX_EBELP.
exit.
else.
gv_ebelp = gv_ebelp + 10.
endif.
enddo.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
ReplyDeleteEXPORTING
* I_STYLE_TABLE =
IT_FIELDCATALOG = IT_FLDCAT
* I_LENGTH_IN_BYTE =
IMPORTING
EP_TABLE = NEW_TABLE
* E_STYLE_FNAME =
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ASSIGN NEW_TABLE->* TO .
* Create dynamic work area and assign to FS
CREATE DATA NEW_LINE LIKE LINE OF .
ASSIGN NEW_LINE->* TO .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form BUILD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_DATA .
sort gt_ekko by ebeln.
sort gt_ekpo by ebeln ebelp.
loop at gt_ekko into gs_ekko.
clear : .
clear : FIELDNAME, FIELDVALUE.
FIELDNAME = 'EBELN'.
FIELDVALUE = gs_ekko-ebeln.
CONDENSE FIELDVALUE.
ASSIGN COMPONENT FIELDNAME OF STRUCTURE TO .
= FIELDVALUE.
loop at gt_ekpo into gs_ekpo WHERE ebeln = gs_ekko-ebeln.
clear : FIELDNAME, FIELDVALUE.
CONCATENATE gs_ekpo-ebelp '_MATNR' into FIELDNAME.
FIELDVALUE = gs_ekpo-matnr.
CONDENSE FIELDVALUE.
ASSIGN COMPONENT FIELDNAME OF STRUCTURE TO .
= FIELDVALUE.
clear : FIELDNAME, FIELDVALUE.
CONCATENATE gs_ekpo-ebelp '_TXZ01' into FIELDNAME.
FIELDVALUE = gs_ekpo-TXZ01.
CONDENSE FIELDVALUE.
ASSIGN COMPONENT FIELDNAME OF STRUCTURE TO .
= FIELDVALUE.
clear : FIELDNAME, FIELDVALUE.
CONCATENATE gs_ekpo-ebelp '_MENGE' into FIELDNAME.
FIELDVALUE = gs_ekpo-menge.
CONDENSE FIELDVALUE.
ASSIGN COMPONENT FIELDNAME OF STRUCTURE TO .
= FIELDVALUE.
clear : FIELDNAME, FIELDVALUE.
CONCATENATE gs_ekpo-ebelp '_NETWR' into FIELDNAME.
FIELDVALUE = gs_ekpo-netwr.
CONDENSE FIELDVALUE.
ASSIGN COMPONENT FIELDNAME OF STRUCTURE TO .
= FIELDVALUE.
clear : gs_ekpo.
endloop.
append to .
clear : gs_ekko.
endloop.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ALV_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_DISPLAY .
GS_LAYOUT1-COL_OPT = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT_LVC = GS_LAYOUT1
IT_FIELDCAT_LVC = IT_FLDCAT[]
* I_GRID_SETTINGS = gs_grid
* IT_EVENTS = lt_evts[]
* IT_EVENTS = I_EVENTS
I_DEFAULT = 'X'
I_SAVE = 'A'
* IS_VARIANT = GS_VARIANT1
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB =
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.