Problem in sort for factory method ALV
Hi,
I am using CL_SALV_TABLE for displaying a ALV with the help of factory method.
Here I am using sort. If I put sort on integer field one exception is coming.
Subtotals cannot be calculated on aggregatable col.
Can anyone solve my problem....thanks in advance....
Amitava
I got it .
The reason why you are getting that message is Subtotals cannot be performed on Number ,Qty or Currency fields.
SEATSOCC is of type INT. so that is the reason it is giving the message.I changed SEATSOCC to CARRID it is working fine for me.
REPORT zsalv_demo message-id zz.
TABLES: sflight.
DATA:
t_sflight LIKE TABLE OF sflight,
salv TYPE REF TO cl_salv_table.
DATA:
functions TYPE REF TO cl_salv_functions_list.
SELECT-OPTIONS:
s_carid FOR sflight-carrid.
START-OF-SELECTION.
*-Get data
SELECT *
FROM sflight
INTO TABLE t_sflight
UP TO 10 ROWS
WHERE carrid IN s_carid.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = if_salv_c_bool_sap=>false
IMPORTING
r_salv_table = salv
CHANGING
t_table = t_sflight.
CALL METHOD salv->get_functions
RECEIVING
value = functions.
CALL METHOD functions->set_all.
CALL METHOD salv->display.
DATA: l_oref_sorts TYPE REF TO cl_salv_sorts,
l_except1 TYPE REF TO cx_salv_not_found, "Exception
l_except2 TYPE REF TO cx_salv_existing, "Exception
l_except3 TYPE REF TO cx_salv_data_error, "Exception
l_text1 TYPE string. "Exception msg
* get the SORTS object
l_oref_sorts = salv->get_sorts( ).
TRY.
CALL METHOD l_oref_sorts->add_sort
EXPORTING
columnname = 'CARRID' "SEATSOCC
position = 1.
CATCH cx_salv_not_found INTO l_except1.
l_text1 = l_except1->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
CATCH cx_salv_existing INTO l_except2.
l_text1 = l_except2->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
CATCH cx_salv_data_error INTO l_except3.
l_text1 = l_except3->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
Similar Messages
-
Regarding problem in cardinality for context in alv display
Hello,
I have a problem with caridianalty with context when displaying in alv. If the cardinality is 1..N then its displaying the data in alv. But if cardinality is changed to 0..N then its giving a cardinality error.
what i want to do is if the internal table is empty i should refresh the alv with the no records for the second time. so please let me know if there is any method to bind the alv with empty internal table.
Regards
Anil Kumar KHi Anil.....
Hope So Following Link will help-ful for u regarding Model-Binding and Data Binding....
1.http://help.sap.com/saphelp_erp2005/helpdata/en/89/5d3d4d4d28c84eb01c635d95a93e0f/frameset.htm
2.http://help.sap.com/saphelp_erp2005/helpdata/en/8f/db0c533a4e514d9720ed2307a40f84/frameset.htm
3.http://help.sap.com/saphelp_erp2005/helpdata/en/fb/fbb84c20df274aa52a0b0833769057/frameset.htm
Best Regard's
Dheerendra -
ALV GRID DISPLAY USING FACTORY METHODS
Hi all
I am using factory methods for my alv grid display.
I have a list of functionalities, for which i am not able to find a correct method..
1) Header of alv(with all the values of the selection-screen)
2)How to give text to a subtotal(ed) column, i.e. if i subtotal a qty field against a sorted field, i want to display ==> Nett Wt. = 123.00 (for first header entry) and so on for each header entry.
3)how to remove the zeroes from a quantity field?
4) Displaying the cells as blanks where data is 0( for quantity fields if i have a cell with zero value, it should be blank.)
5) double click on a cell to open a transaction with the cell's value.
Any help on this would be appreciated.
Points will be rewarded for sure...
Thanks & Regards
Ravish GargHello Ravish
Regarding the display of zero values as empty cells have a look at my <i>modified </i>sample report <b>ZUS_SDN_CL_SALV_TABLE_INTERACT</b>.
*& Report ZUS_SDN_CL_SALV_TABLE_INTERACT
REPORT zus_sdn_cl_salv_table_interact.
TYPE-POOLS: abap.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1.
DATA:
go_table TYPE REF TO cl_salv_table,
go_events TYPE REF TO cl_salv_events_table.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT
if_salv_events_actions_table~double_click
OF cl_salv_events_table
IMPORTING
row
column.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
lo_table TYPE REF TO cl_salv_table,
lt_orders TYPE STANDARD TABLE OF bapiorders,
ls_knb1 TYPE knb1.
READ TABLE gt_knb1 INTO ls_knb1 INDEX row.
IF ( syst-subrc = 0 ).
CALL FUNCTION 'BAPI_SALESORDER_GETLIST'
EXPORTING
customer_number = ls_knb1-kunnr
sales_organization = '1000'
* MATERIAL =
* DOCUMENT_DATE =
* DOCUMENT_DATE_TO =
* PURCHASE_ORDER =
* TRANSACTION_GROUP = 0
* PURCHASE_ORDER_NUMBER =
* IMPORTING
* RETURN =
TABLES
sales_orders = lt_orders.
* Create ALV grid instance
TRY.
CALL METHOD cl_salv_table=>factory
* EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
r_salv_table = lo_table
CHANGING
t_table = lt_orders.
CATCH cx_salv_msg .
ENDTRY.
lo_table->display( ).
** SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
** SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
** CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDIF.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = '1000'.
* Create ALV grid instance
TRY.
CALL METHOD cl_salv_table=>factory
* EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
r_salv_table = go_table
CHANGING
t_table = gt_knb1.
CATCH cx_salv_msg .
ENDTRY.
* Create event instance
go_events = go_table->get_event( ).
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_double_click FOR go_events.
PERFORM modify_columns.
go_table->display( ).
END-OF-SELECTION.
*& Form MODIFY_COLUMNS
* text
* --> p1 text
* <-- p2 text
FORM modify_columns .
* define local data
DATA:
lt_dfies TYPE ddfields,
ls_dfies TYPE dfies,
lo_typedescr TYPE REF TO cl_abap_typedescr,
lo_strucdescr TYPE REF TO cl_abap_structdescr,
lo_tabledescr TYPE REF TO cl_abap_tabledescr,
lo_columns TYPE REF TO cl_salv_columns_table,
lo_column TYPE REF TO cl_salv_column.
lo_columns = go_table->get_columns( ).
lo_typedescr = cl_abap_typedescr=>describe_by_data( gt_knb1 ).
lo_tabledescr ?= lo_typedescr.
lo_strucdescr ?= lo_tabledescr->get_table_line_type( ).
lt_dfies = lo_strucdescr->get_ddic_field_list( ).
LOOP AT lt_dfies INTO ls_dfies.
lo_column = lo_columns->get_column( ls_dfies-fieldname ).
IF ( ls_dfies-keyflag = abap_true ).
CONTINUE.
ELSEIF ( ls_dfies-fieldname = 'WEBTR' ). " Bill of ex. limit
lo_column->set_zero( if_salv_c_bool_sap=>true ). " display zero
lo_column->set_zero( if_salv_c_bool_sap=>false ). " hide zero
ELSE.
lo_column->set_technical( if_salv_c_bool_sap=>true ). " hide col
ENDIF.
ENDLOOP.
ENDFORM. " MODIFY_COLUMNS
Regards
Uwe -
Hi all
I am using <b>factory methods for my alv grid display.</b>
I have a list of functionalities, for which i am not able to find a correct method..
1) Header of alv(with all the values of the selection-screen) along with labels
2)How to give text to a subtotal(ed) column, i.e. if i subtotal a qty field against a sorted field, i want to display ==> Nett Wt. = 123.00 (for first header entry) and so on for each header entry.
3)how to remove the zeroes from a quantity field?
4) Displaying the cells as blanks where data is 0( for quantity fields if i have a cell with zero value, it should be blank.)
5) double click on a cell to open a transaction with the cell's value.
6) how to have multiple subtotal columns, without disturbing the sort order of grid display
Any help on this would be appreciated.
Points will be rewarded for sure...
Thanks & Regards
Ravish GargHello Ravish
Regarding the handling of the <u>double-click</u> event have a look at sample report <b>ZUS_SDN_CL_SALV_TABLE_INTERACT</b>.
*& Report ZUS_SDN_CL_SALV_TABLE_INTERACT
REPORT zus_sdn_cl_salv_table_interact.
TYPE-POOLS: abap.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1.
DATA:
go_table TYPE REF TO cl_salv_table,
go_events TYPE REF TO cl_salv_events_table.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT
if_salv_events_actions_table~double_click
OF cl_salv_events_table
IMPORTING
row
column.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
lo_table TYPE REF TO cl_salv_table,
lt_orders TYPE STANDARD TABLE OF bapiorders,
ls_knb1 TYPE knb1.
READ TABLE gt_knb1 INTO ls_knb1 INDEX row.
IF ( syst-subrc = 0 ).
CALL FUNCTION 'BAPI_SALESORDER_GETLIST'
EXPORTING
customer_number = ls_knb1-kunnr
sales_organization = '1000'
* MATERIAL =
* DOCUMENT_DATE =
* DOCUMENT_DATE_TO =
* PURCHASE_ORDER =
* TRANSACTION_GROUP = 0
* PURCHASE_ORDER_NUMBER =
* IMPORTING
* RETURN =
TABLES
sales_orders = lt_orders.
* Create ALV grid instance
TRY.
CALL METHOD cl_salv_table=>factory
* EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
r_salv_table = lo_table
CHANGING
t_table = lt_orders.
CATCH cx_salv_msg .
ENDTRY.
lo_table->display( ).
** SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
** SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
** CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDIF.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = '1000'.
* Create ALV grid instance
TRY.
CALL METHOD cl_salv_table=>factory
* EXPORTING
* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
* R_CONTAINER =
* CONTAINER_NAME =
IMPORTING
r_salv_table = go_table
CHANGING
t_table = gt_knb1.
CATCH cx_salv_msg .
ENDTRY.
* Create event instance
go_events = go_table->get_event( ).
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_double_click FOR go_events.
go_table->display( ).
END-OF-SELECTION.
Regards
Uwe -
How to add a new button in an ALV using factory method
im using factory method to creat an ALV
The reason why I'm doing this is because I want the ALV and the selection screen in the same screen like exemplified here http://help-abap.blogspot.com/2008/10/dispaly-alv-report-output-in-same.html
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = if_salv_c_bool_sap=>false
r_container = lo_cont
container_name = 'DOCK_CONT'
IMPORTING
r_salv_table = lo_alv
CHANGING
t_table = me->t_data.
The above code already uses every parameter that method as to offer.
Is it possible to add extra buttons to an ALV using that method?Hi Ann,
The reason you are not able to see any of the new columns as a option to select in your web service block is because when you have published that block, they were not present. Add these two new objects in your block and publish it again. You will be prompted for duplication content. Select the highlighted block for duplicate and now you can see the new added objects in the filter option. Update and this will overwrite your published block. Please note, web services do appear to behave weirdly when used with dashboards so I request you to please try it in a separate test report first.
Hope that helps.
Regards,
Tanisha -
Problem in factory method, how to pass arguments ?
Hello it's me again :)
here's the code :
package print;
import java.util.*;
import static print.Print.*;
interface Fact<T> {
T create(String n);;
T create ();
class PetColl {
public String toString() {
return getClass().getSimpleName();
static List<Fact<? extends Pet>> petSpecies=
new ArrayList<Fact<? extends Pet>>();
static {
// Collections.addAll() gives an "unchecked generic
// array creation ... for varargs parameter" warning.
petSpecies.add(new Cymric.Factory());
petSpecies.add(new EgyptianMau.Factory());
petSpecies.add(new Hamster.Factory());
petSpecies.add(new Manx.Factory());
petSpecies.add(new Mouse.Factory());
petSpecies.add(new Pug.Factory());
petSpecies.add(new Mutt.Factory());
petSpecies.add(new Rat.Factory());
private static Random rand = new Random(47);
public static Pet createRandom() {
int n = rand.nextInt(petSpecies.size());
return petSpecies.get(n).create();
public Pet[] createArray(int size) {
Pet[] result = new Pet[size];
for(int i = 0; i < size; i++)
result[i] = createRandom();
return result;
public ArrayList<Pet> arrayList(int size) {
ArrayList<Pet> result = new ArrayList<Pet>();
Collections.addAll(result, createArray(size));
return result;
class Individual implements Comparable<Individual> {
private static long counter = 0;
private final long id = counter++;
private String name;
public Individual(String name) { this.name = name; }
// ?name? is optional:
public Individual() {}
public String toString() {
return getClass().getSimpleName() +
(name == null ? "" : " " + name);
public long id() { return id; }
public boolean equals(Object o) {
return o instanceof Individual &&
id == ((Individual)o).id;
public int hashCode() {
int result = 17;
if(name != null)
result = 37 * result + name.hashCode();
result = 37 * result + (int)id;
return result;
public int compareTo(Individual arg) {
// Compare by class name first:
String first = getClass().getSimpleName();
String argFirst = arg.getClass().getSimpleName();
int firstCompare = first.compareTo(argFirst);
if(firstCompare != 0)
return firstCompare;
//second compare by name
if(name != null && arg.name != null) {
int secondCompare = name.compareTo(arg.name);
if(secondCompare != 0)
return secondCompare;
}//third compare by id
return (arg.id < id ? -1 : (arg.id == id ? 0 : 1));
class Pets {
public static final PetColl creator =
//new LiteralPetCreator();
new PetColl();
public static Pet randomPet() {
return creator.createRandom();
public static Pet[] createArray(int size) {
return creator.createArray(size);
public static ArrayList<Pet> arrayList(int size) {
return creator.arrayList(size);
class Person extends Individual {
String name;
public static class Factory implements Fact<Person>{
public Person create(String name){
Person.name=name;
return new Person(); }
public Person create(){return new Person();}
class Pet extends Individual {
class Dog extends Pet {
class Mutt extends Dog {
public static class Factory implements Fact<Mutt> {
public Mutt create(String name){return new Mutt(name);}
public Mutt create () {return new Mutt();}
class Pug extends Dog {
public static class Factory implements Fact<Pug> {
public Pug create(String name){return new Pug(name);}
public Pug create () {return new Pug();}
class Cat extends Pet {
class EgyptianMau extends Cat {
public static class Factory implements Fact<EgyptianMau> {
public EgyptianMau create(String name){return new EgyptianMau(name);}
public EgyptianMau create () {return new EgyptianMau();}
class Manx extends Cat {
public static class Factory implements Fact<Manx> {
public Manx create(String name){return new Manx(name);}
public Manx create () {return new Manx();}
class Cymric extends Manx {
public static class Factory implements Fact<Cymric> {
public Cymric create(String name){return new Cymric(name);}
public Cymric create () {return new Cymric();}
class Rodent extends Pet {
class Rat extends Rodent {
public static class Factory implements Fact<Rat> {
public Rat create(String name){return new Rat(name);}
public Rat create () {return new Rat();}
class Mouse extends Rodent {
public static class Factory implements Fact<Mouse> {
public Mouse create(String name){return new Mouse(name);}
public Mouse create () {return new Mouse();}
class Hamster extends Rodent {
public static class Factory implements Fact<Hamster> {
public Hamster create(String name){return new Hamster(name);}
public Hamster create () {return new Hamster();}
public class Test {
public static void main(String[] args) {
for(Pet p:Pets.creator.arrayList(25)){
PetCount.petC.count(p.getClass().getSimpleName());
print(p.getClass().getSimpleName());}
class PetCount {
static class PetCounter extends HashMap<String,Integer> {
public void count(String type) {
Integer quantity = get(type);
if(quantity == null)
put(type, 1);
else
put(type, quantity + 1);
public static PetCounter petC= new PetCounter();
}and here's my problem:
I'm trying to fill up list using factory method but in a fact that I want to have two constructors, I have a problem to set field name of objects of those classes. Is there any possibility to use in that way some factory method to create that list ?
In Person class I've tried to set it in factory method before creating an object, but as you know that option is only alvailable for static fields which i don't want to be static.I for one have no idea what you're asking, and what you seem to be saying doesn't make sense.
I'm trying to fill up list using factory method but in a fact that I want to have two constructors,Two constructors for what? The factory class? The classes that the factory instantiates?
I have a problem
to set field name of objects of those classes. Is there any possibility to use in that way some factory method to
create that list ?What?
In Person class I've tried to set it in factory method before creating an object, but as you know that option is only alvailable for static fields which i don't want to be static.That doesn't make any sense. A Factory can easily set fields in the objects it creates on the fly (not static). -
How to disable sorting for some columns in a ALV GRID?
Hi i have requirement where I have to disable sorting for some columns in a ALV GRID. i am using REUSE_ALV_GRID_DISPLAY function module.
Can anybody help me. how to acieve this? Any code snippets will really be appreciated.Hi,
I have tried this but not completely successful. I think this can be done using the OOPS method.
DATA: it_event_exit TYPE slis_t_event_exit.
DATA: w_exit TYPE slis_event_exit.
w_exit-ucomm = '&ODN'.
w_exit-before = 'X'.
CLEAR w_exit-after.
APPEND w_exit TO it_event_exit.
w_exit-ucomm = '&OUP'.
w_exit-before = 'X'.
CLEAR w_exit-after.
APPEND w_exit TO it_event_exit.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_repid
i_callback_top_of_page = 'ALV_TOP_OF_PAGE'
i_callback_html_top_of_page = 'ALV_HTML_TOP_OF_PAGE'
i_callback_user_command = 'USER_COMMAND' <- User command form
is_layout = wm_layout
it_fieldcat = wt_fieldcat
it_events = i_events
it_event_exit = it_event_exit <- Need to fill
it_sort = wt_sort
i_default = 'X'
Now you can capture this events in the user command
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
IF r_ucomm = '&OUP' and rs_selfield-SEL_TAB_FIELD = 'Your field name'.
ENDIF.
ENDFORM. "user_command
In this form you will get the function code in 'r_ucomm' and the field selected for sorting in 'rs_selfield-SEL_TAB_FIELD'. But reseting 'r_ucomm' will not work.
May be somebody else can give some help on this.
But this will work if you follow the oop method.
Please see this document for more info.
http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an easy reference for alv grid control.pdf
Thanks
Vinod -
Coloring an single field of an ALV using factory method
how can we color just a single field in ALV using factory method.
Hello Regi you may want to check this sample code, basically what you need is to use the lvc_s_colo structure and the set_color method of the class cl_salv_column_table.
METHOD set_colors.
*.....Color for COLUMN.....
DATA: lo_cols_tab TYPE REF TO cl_salv_columns_table,
lo_col_tab TYPE REF TO cl_salv_column_table.
DATA: ls_color TYPE lvc_s_colo. " Colors strucutre
* get Columns object
lo_cols_tab = co_alv->get_columns( ).
INCLUDE <color>.
* Get ERDAT column & set the yellow Color fot it
TRY.
lo_col_tab ?= lo_cols_tab->get_column( 'ERDAT' ).
ls_color-col = col_total.
lo_col_tab->set_color( ls_color ).
CATCH cx_salv_not_found.
ENDTRY.
*.......Color for Specific Cell & Rows.................
* Applying color on the 3rd Row and Column AUART
* Applying color on the Entire 5th Row
DATA: lt_s_color TYPE lvc_t_scol,
ls_s_color TYPE lvc_s_scol,
la_vbak LIKE LINE OF ct_vbak,
l_count TYPE i.
LOOP AT ct_vbak INTO la_vbak.
l_count = l_count + 1.
CASE l_count.
* Apply RED color to the AUART Cell of the 3rd Column
WHEN 3.
ls_s_color-fname = 'AUART'.
ls_s_color-color-col = col_negative.
ls_s_color-color-int = 0.
ls_s_color-color-inv = 0.
APPEND ls_s_color TO lt_s_color.
CLEAR ls_s_color.
* Apply GREEN color to the entire row # 5
* For entire row, we don't pass the Fieldname
WHEN 5.
ls_s_color-color-col = col_positive.
ls_s_color-color-int = 0.
ls_s_color-color-inv = 0.
APPEND ls_s_color TO lt_s_color.
CLEAR ls_s_color.
ENDCASE.
* Modify that data back to the output table
la_vbak-t_color = lt_s_color.
MODIFY ct_vbak FROM la_vbak.
CLEAR la_vbak.
CLEAR lt_s_color.
ENDLOOP.
* We will set this COLOR table field name of the internal table to
* COLUMNS tab reference for the specific colors
TRY.
lo_cols_tab->set_color_column( 'T_COLOR' ).
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.
ENDMETHOD. "set_colors -
Multiple ALV display using SALV(Factory method)...
Hello Experts,
Please provide me any examples on how to display multiple ALV
displays in a screen using SALV(Factory method).
Hope you can help me guys.
Thank you and take care!Hi Viraylab,
Kindly check the program below, this will help you..
*& Report Z101754_REPORT
REPORT z101754_report.
TABLES: zvbak_101754,zvbap_101754,mara.
TYPE-POOLS: slis.
DATA : i_fieldcat TYPE slis_t_fieldcat_alv.
DATA: FLDNAME(24).
DATA : BEGIN OF itab_zvbap OCCURS 0,
zvbeln LIKE zvbap_101754-zvbeln,
zposnr LIKE zvbap_101754-zposnr,
zmatnr LIKE zvbap_101754-zmatnr,
zbrgew LIKE zvbap_101754-zbrgew,
zgi_qty LIKE zvbap_101754-zgi_qty,
zinv_qty LIKE zvbap_101754-zinv_qty,
END OF itab_zvbap.
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-t01.
SELECT-OPTIONS : s_zvbeln FOR zvbak_101754-zvbeln,
s_zkunwe FOR zvbak_101754-zkunwe,
s_zerdat FOR zvbak_101754-zerdat,
s_zmatnr FOR zvbap_101754-zmatnr.
SELECTION-SCREEN END OF BLOCK block1.
SELECTION-SCREEN: BEGIN OF BLOCK block2 WITH FRAME TITLE t02.
PARAMETERS : invoiced AS CHECKBOX,
s_gi AS CHECKBOX .
SELECTION-SCREEN: END OF BLOCK block2.
SELECTION-SCREEN: BEGIN OF BLOCK block3 WITH FRAME TITLE t03.
PARAMETERS : alv_list RADIOBUTTON GROUP g1,
alv_grid RADIOBUTTON GROUP g1,
s_class RADIOBUTTON GROUP g1.
SELECTION-SCREEN: END OF BLOCK block3.
Screen Field Validation event
AT SELECTION-SCREEN ON s_zvbeln.
SELECT SINGLE *
FROM zvbak_101754 WHERE zvbeln IN s_zvbeln.
IF sy-subrc NE 0.
MESSAGE e000(z754).
ENDIF.
AT SELECTION-SCREEN ON s_zkunwe.
SELECT SINGLE *
FROM zvbak_101754 WHERE zkunwe IN s_zkunwe.
IF sy-subrc NE 0.
MESSAGE e001(z754).
ENDIF.
AT SELECTION-SCREEN ON s_zerdat.
SELECT SINGLE *
FROM zvbak_101754 WHERE zerdat IN s_zerdat.
IF sy-subrc NE 0.
MESSAGE e002(z754).
ENDIF.
AT SELECTION-SCREEN ON s_zmatnr.
SELECT SINGLE *
FROM zvbap_101754 WHERE zmatnr IN s_zmatnr.
IF sy-subrc NE 0.
MESSAGE e003(z754).
ENDIF.
Start-Of-Selection Event
START-OF-SELECTION.
PERFORM select-data.
End-Of-Selection Event
END-OF-SELECTION.
PERFORM display.
*& Form select-data
text
--> p1 text
<-- p2 text
FORM select-data .
SELECT zvbeln zposnr zmatnr zbrgew zgi_qty zinv_qty
INTO CORRESPONDING FIELDS OF TABLE itab_zvbap
FROM zvbap_101754
WHERE zvbeln IN s_zvbeln.
ENDFORM. " select-data3
TOP-OF-PAGE.
AT LINE-SELECTION.
FORMAT HOTSPOT.
*GET THE FIELD NAME ON LINE SELECTION
GET CURSOR FIELD FLDNAME . "value field_value.
IF FLDNAME = 'itab_zvbap-zvbeln'.
SET PARAMETER ID 'BES' FIELD itab_zvbap-zvbeln.
CALL TRANSACTION 'ZVA01_101754'.
ENDIF.
*& Form DISPLAY
text
--> p1 text
<-- p2 text
FORM display .
IF s_class ='X'.
PERFORM display_header.
LOOP AT itab_zvbap.
WRITE : / sy-vline,
itab_zvbap-zvbeln ,
13 sy-vline,
itab_zvbap-zposnr ,
30 sy-vline,
itab_zvbap-zmatnr ,
45 sy-vline,
itab_zvbap-zbrgew UNIT mara-meins ,
65 sy-vline,
itab_zvbap-zgi_qty UNIT mara-meins,
85 sy-vline,
itab_zvbap-zinv_qty UNIT mara-meins,
105 sy-vline,
/ sy-uline(105).
ENDLOOP.
ENDIF.
*& Creating the fieldcatalog.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB_ZVBAP'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = sy-repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = i_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF alv_list = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
i_callback_pf_status_set = ' '
i_callback_user_command = 'USER_COMMAND '
I_STRUCTURE_NAME =
IS_LAYOUT =
it_fieldcat = i_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IR_SALV_LIST_ADAPTER =
IT_EXCEPT_QINFO =
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = itab_zvbap[]
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'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
i_callback_pf_status_set = ' '
i_callback_user_command = 'USER_COMMAND '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = i_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = itab_zvbap[]
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 display_header
text
--> p1 text
<-- p2 text
FORM display_header .
WRITE : / sy-vline,
'ORDER NO',
13 sy-vline,
'ITEM NO',
30 sy-vline,
'MATERIAL NO',
45 sy-vline,
'ORDER QTY',
65 sy-vline,
'GI QTY',
85 sy-vline,
'INVOICED QTY',
105 sy-vline,
/ sy-uline(105).
ENDFORM. " display_header
Please let me know if you have any doubt.
Regards,
Amit. -
LOGO required in ALV top of page using factory method
Hi,
I am doing an ALV using factory method of class Cl_SALV_TABLE. Can any one help me about putting a LOGO on the top of page.
Thanks in advance.
AmitavaHi,
In START-OF-SELECTION.
put form to display header
like PERFORM build_header
gr_table->display( ).
then...
in FORM
FORM build_header.
lr_grid TYPE REF TO cl_salv_form_layout_grid,
lr_logo TYPE REF TO cl_salv_form_layout_logo,
create object lr_logo.
lr_logo->set_left_content( lr_grid ).
lr_logo->set_right_logo( 'LOGO_NAME' ).
* Set the element top_of_list
gr_table->set_top_of_list( lr_logo ).
ENDFORM.
thanx. -
Back button issue in ALV Grid(Factory method)
Hi All,
I have displayed a report using factory method(CL_SALV_TABLE).In that i have added buttons in application bar too.So when clicking on refresh button ALV should display again with latest number of records,that is working fine but when clicking on back button it should go to selection screen instead of that it is going a step back and displaying previous list of grid and then back and then selection screen.
Can any one help me how to directly go to input selection screen instead of going step back...
Regards,
RamHI,
Use this syntax (CALL SELECTION-SCREEN 1000)...Try this one
regards,
balaji -
Create Excise invoice for Factory Sale problem
Dear Friends:
Using T.code J1IIN ( Create Excise invoice for Factory Sale), I entered data for billing doc,posting date,sub transaction type & pressed enter and tried to save it.I got the error 'Error in allocating internal document number interval not found number object J_1IINTNUM'.
Using T.code J1I9, I used the number object J_1IINTNUM and created number ranges and again tried to save T.code J1IIN ( Create Excise invoice for Factory Sale), but still i am getting the same error.
Please let me know how to solve the error.Please explain in detail.This will be highly Appreciated.
Thanks
SridharHi Sridhar,
Can you please let me know whether your issue is resolved. If yes, Can you please specify the solution.
I am facing the same error now and I am not able to figure out the reason for it.
Regards,
Srinu NV -
Factory methods and downcasting
I am having a class hierarchy and a factory method that creates the classes from this hierarchy. The factory method returns the root class of this hierarchy and every time I want to use a class specific method of one of the sub classes I will have to check the type of this class and cast to this class type. My question is now if there is a possibility to avoid the type checking and casting or if this is one of the few situations where type checking and casting is approriate. To illustrate the problem here is some code:
class Factory {
public static A create() {
if (//someCondition)
return new B();
else
return new C();
abstract class A {
public void commonMethod() {
// do stuff
public void polymorphicMethod();
class B extends A {
public void polymorphicMethod() {
// do something
public void specificBMethod() {
// do stuff that only B can do
class C extends A {
public void polymorphicMethod() {
// do some other thing
public void specificCMethod() {
// do stuff that only C can do
}Now I run into a situation where I have to downcast to the correct type.
class Worker {
public void work() {
A a = Factory.create();
if (a instanceof B) {
( (B) a).specificBMethod();
} else if (a instanceof C) {
( (C) a).specificCMethod();
} else {
// Error
}I think this problem always arises if you have a factory method that returns a class at the top of the hierarchy or a interface but you can not put all the methods that a client wants to call in this common class or interface. Is there a better a way to do this or is this already a good solution?In my particular case I have an XML parser that
parses messages. I implemented each different message
type as a different class and the parser uses the
factory to create new message objects. The parser
then uses methods that are defined in the topmost
Message class and in an interface to set the
attributes of the object. Each message class
overrides a "handleXMLElement" method defining how to
deal with the message specific XML elements. So this
is fine the parser is the client of the factory and
he uses only methods that are defined in a common
class and an interface.
After a message has been read the message object is
forwarded to a hierarchy of message handlers. Of
course the message handlers know of the message class
hierarchy and want to access all methods of each
message object. But since the parser only knows about
the interface and the common class, the message
handlers will have to cast the message objects to the
concrete types.If the message type that's passed in has its behavior in the common interface, why is there a need to cast?
So the parser-factory relationship works well but the
(nasty) casting arises due to the later message
handling. Maybe your message handling needs redesign. Or perhaps a hierarchy of callback objects that let you customize that part that changes for each message.
I also remembered why I implemented it this
way. In the Desing Patterns book of Gamma et. al.
the Chain of Responsibility pattern can be
implemented this way using casts. So the solution
can't be that bad at all, I guess.Don't take that as gospel. GoF isn't perfection. Patterns can be misapplied.
@stefan: I can't pull all my methods from the
subclasses in one upper class, because the methods
are different and specialised for each sub class. I
don't think that it is good when one sub class knows
all the methods of all other sub classes.Maybe a callback object can help sort this out. I think you need a redesign to eliminate the casts. More thinking is required.
% -
Need a sample program for hierarchial oops ALV report
Hello experts,
I Need a sample program for hierarchial oops ALV report.Hi,
Check the following sample code...
T A B L E S
tables : ekko.
data definition
types : begin of ty_ekko,
ebeln type ekko-ebeln,
lifnr type ekko-lifnr,
bsart type ekko-bsart,
aedat type ekko-aedat,
ernam type ekko-ernam,
end of ty_ekko.
types : begin of ty_eket,
ebeln type ekpo-ebeln,
ebelp type ekpo-ebelp,
werks type ekpo-werks,
matnr type ekpo-matnr,
menge type eket-menge,
wamng type eket-wamng,
netpr type ekpo-netpr,
end of ty_eket.
data : it_ekko type table of ty_ekko,
it_eket type table of ty_eket.
data: ob_hieralv type ref to cl_salv_hierseq_table.
data: it_binding type salv_t_hierseq_binding,
is_binding type salv_s_hierseq_binding.
S E L C T O P T I O N S
select-options : s_ebeln for ekko-ebeln.
S T A R T O F S E L E C T I O N
start-of-selection.
select ebeln
lifnr
bsart
aedat
ernam from ekko
into corresponding fields of table it_ekko
where ebeln in s_ebeln.
if sy-subrc eq 0.
select aebeln aebelp
awerks amatnr
bmenge bwamng
a~netpr from ekpo as a join eket as b
on amandt = bmandt
and aebeln = bebeln
and aebelp = bebelp
into corresponding fields of table it_eket
where a~ebeln in s_ebeln.
endif.
is_binding-master = 'EBELN'.
is_binding-slave = 'EBELN'.
append is_binding to it_binding.
*TRY.
call method cl_salv_hierseq_table=>factory
exporting
t_binding_level1_level2 = it_binding
importing
r_hierseq = ob_hieralv
changing
t_table_level1 = it_ekko
t_table_level2 = it_eket .
*CATCH cx_salv_data_error .
*CATCH cx_salv_not_found .
*ENDTRY.
call method ob_hieralv->display( ).
Cheers,
Ram -
Trying to understand Objective C warning related to factory method
All,
I'm just beginning learning objective C (I am a C++ programmer by day), and I have a question about a warning I am seeing in my code. I found some really simple example code on the web that used the 'new' factory method to create an instance of an object. Here are the three files:
List.h
#import <objc/Object.h>
@interface List : Object // List is a subclass of the superclass Object
int list[100]; // These are instance variables.
int size;
/* Public methods */
- free;
- (int) addEntry: (int) num;
- print;
/* Private methods */
/* Other programs should not use these methods. */
- resetSize;
@end
List.m
#import "List.h"
@implementation List
+ new // factory method
self = [super new];
printf("inside new\n");
[self resetSize];
return self;
- free
return [super free];
- (int) addEntry: (int) num
list[size++] = num;
return size;
- print
int i;
printf("\n");
for (i = 0; i < size; ++i)
printf ("%i ", list);
return self; // Always return self
// if nothing else makes sense.
- resetSize
printf("Inside resetSize\n");
size = 0;
return self;
@end
main.m
#import <objc/Object.h>
#import "List.h" // Note the new commenting style.
main()
id list; // id is a new data type for objects.
list = [List new]; // create an instance of class List.
[list resetSize];
[list addEntry: 5]; // send a message to the object list
[list print];
[list addEntry: 6];
[list addEntry: 3];
[list print];
printf("\n");
[list free]; // get rid of object
Now, I know that the 'best' way to allocate and initialize an object is through [[List alloc] init], but I'm seeing a strange warning when I compile List.m, and I just want to understand why it's showing up. Here's the warning.
List.m: In function ‘+[List new]’:
List.m:9: warning: ‘List’ may not respond to ‘+resetSize’
List.m:9: warning: (Messages without a matching method signature
List.m:9: warning: will be assumed to return ‘id’ and accept
List.m:9: warning: ‘...’ as arguments.)
It looks like something is assuming that resetSize is a factory method rather than an instance method. The strange thing, though, is that the program works exactly like expected. resetSize is actually called from within the new method correctly.
Any ideas why I'm seeing the error, and how I should get rid of it?
Thanks,
EricThanks for clearing that up for me - it makes sense now. And sorry about the formatting problems - I guess forgetting the {code} tags make a pretty big difference
It's taking a little bit for my mind to switch from C++ syntax to Objective C, but I'm able to visualize the problem and the reason the code I found produced the error.
Thanks again,
Eric
Maybe you are looking for
-
User exit / badi to change engine serial-number of vehicle in ie02 ??
hi all , does anybody familier with user exit/badi that can handle the screen called : vehicle technology in transaction ie02 for fleet management . i need it in order to update the field : engineserialno that appears in this screen. thanks in regard
-
Time Machine won't allow inProgress file (or any other backup) to be deleted
iMac early 2009 OS X 10.9.5 CCC reported an error with a file (bad sector?) but before I attempted to replace it I found I was unable to re-boot iMac. I have successfully restored from Time Machine but TM will not now undertake further back ups and t
-
Help:Extension Filters exception
Hi All, A)I have included the detailed description of the steps followed.As a part of my new assignment i have been asked to upgrade to Tomahawk1.1.3.I am Websphere RAD to build my application. The application uses custom components <t:inputCalendar>
-
My source // ViewController.m // Calculator // Created by APPLE on 4/6/14. // Copyright (c) 2014 DinhXuanVu. All rights reserved. #import "ViewController.h" @interface ViewController () @end @implementation ViewController -(IBAction)Number1:(id)s
-
Event 50 doc type 30 is not for incoming payment in tcode fpe1 fscd module
Dear Experts i had configured a new company code and done the necessary configuration changes in the FSCD collection and disbursement module but while posting a document in FPE1 in FSCD i am unable to post a document . At present i am getting the fol