OOPS Program for rectification.
Hi Experts!!
This program is syntatically correct. But output not Coming.
Prerequisite : Screen no 100
Container Name: Container.
*& Report ZSAP_OBJECT *
REPORT zsap_object .
CLASS select_display_sflight DEFINITION
CLASS select_display_sflight DEFINITION.
PUBLIC SECTION.
TYPES: BEGIN OF s_sflight_tab,
connid TYPE sflight-connid,
carrid TYPE sflight-carrid,
END OF s_sflight_tab.
CLASS-METHODS class_constructor.
METHODS: constructor IMPORTING i_carrid TYPE sflight-carrid
i_connid TYPE sflight-connid
EXCEPTIONS nothing_found,
display_flights.
PRIVATE SECTION.
CLASS-DATA list TYPE REF TO cl_gui_alv_grid.
DATA: sflight_tab1 TYPE standard TABLE OF s_sflight_tab,
with unique key carrid,
sflight_Tab type sflight_tab1,
wa_tab TYPE s_sflight_tab.
ENDCLASS. "select_display_sflight DEFINITION
CLASS select_display_sflight IMPLEMENTATION
CLASS select_display_sflight IMPLEMENTATION.
METHOD: class_constructor.
CREATE OBJECT list
EXPORTING i_parent = cl_gui_container=>screen0.
ENDMETHOD. "class_constructor
METHOD constructor.
*select carrid connid into corresponding fields of table sflight_tab1
*from sflight
where carrid = i_carrid and
connid = i_connid.
SELECT carrid connid FROM sflight
INTO CORRESPONDING FIELDS OF wa_tab WHERE carrid = i_carrid AND
connid = i_connid.
comments<b>
<u>I want to move data from wa_tab to sflight_tab1**</b></u>
*move-corresponding wa_tab to sflight_Tab1.
ENDSELECT.
if sy-subrc = 0.
*sflight_tab = wa_tab.
*sflight_tab-connid = wa_tab-connid.
else.
RAISE nothing_found.
ENDIF.
ENDMETHOD. "constructor
"constructor
METHOD display_flights.
CALL METHOD list->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
it_outtab = sflight_tab1.
it_outtab = wa_tab.
CALL SCREEN 100.
ENDMETHOD. "display_flights
ENDCLASS. "select_display_sflight IMPLEMENTATION
SELECTION-SCREEN BEGIN OF SCREEN 500.
PARAMETERS: p_carrid TYPE sflight-carrid,
p_connid TYPE sflight-connid.
SELECTION-SCREEN END OF SCREEN 500.
DATA: BEGIN OF ref_tab_line,
carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
oref TYPE REF TO select_display_sflight,
END OF ref_tab_line,
ref_tab LIKE SORTED TABLE OF ref_tab_line WITH UNIQUE KEY carrid connid.
START-OF-SELECTION.
DO.
CALL SELECTION-SCREEN 500 STARTING AT 10 10.
IF sy-subrc <> 0.
LEAVE PROGRAM.
ENDIF.
ref_tab_line-carrid = p_carrid.
ref_tab_line-connid = p_connid.
READ TABLE ref_tab INTO ref_tab_line FROM ref_tab_line.
IF sy-subrc <> 0.
CREATE OBJECT ref_tab_line-oref
EXPORTING i_carrid = p_carrid
i_connid = p_connid
EXCEPTIONS nothing_found = 4.
IF sy-subrc = 4.
MESSAGE i888(sabapdocu) WITH 'no data'.
ENDIF.
ENDIF.
CALL METHOD ref_tab_line-oref->display_flights.
ENDDO.<u></u>
Thanks in Advance.
Hello Anil
The error is located in the CLASS_CONSTRUCTOR method.
CLASS select_display_sflight IMPLEMENTATION.
METHOD: class_constructor.
CREATE OBJECT list " TYPE REF TO cl_gui_alv_grid
EXPORTING i_parent = cl_gui_container=>screen0.
ENDMETHOD. "class_constructor
The parent of an grid instance always must be a container (e.g. docking container). Thus, simply change your method as following:
METHOD class_constructor.
CREATE go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90.
CREATE go_grid
EXPORTING
parent = go_docking.
" Link the docking container to the screen -> NOTE: In this case no
" custom container is required as screen element.
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
" container = ' ' " optional
ENDMETHOD.
For a sample report (<b>ZUS_SDN_TWO_ALV_GRIDS</b>) have a look at thread
sample alv program using classes & methods ..but not using container
Regards
Uwe
Similar Messages
-
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 -
Hi experts,
When executing a simple oops program ..i got the following error. Please correct the code.
"VAR" is not type-compatible with formal parameter "I_DATA".
CLASS main DEFINITION
CLASS main DEFINITION.
PUBLIC SECTION.
"// Instance Methods ( Note we use the statement 'METHODS'
"// to define an instance method )
METHODS set_data IMPORTING i_data TYPE string.
METHODS get_data RETURNING value(r_data) TYPE string.
METHODS print_attribute IMPORTING i_data TYPE string.
"// Instance Methods ( Note we use the statement 'CLASS-METHODS'
"// to define a static method )
CLASS-METHODS set_classdata IMPORTING i_data TYPE string.
CLASS-METHODS get_classdata RETURNING value(r_data) TYPE string.
CLASS-METHODS print_classattribute IMPORTING i_data TYPE string.
PROTECTED SECTION.
"// Instance Attribute ( Note we use the statement 'DATA'
"// to define an instance attribute )
DATA attribute TYPE string.
"// Static Attribute ( Note we use the statement 'CLASS-DATA'
"// to define a static attribute )
CLASS-DATA classattribute TYPE string.
PRIVATE SECTION.
"// Instace event ( Note we use the statement 'EVENTS'
"// to define aN instance event )
EVENTS event EXPORTING value(e_data) TYPE string.
"// Instace event ( Note we use the statement 'CLASS-EVENTS'
"// to define a static event )
CLASS-EVENTS classevent EXPORTING value(e_data) TYPE string.
"// For more informations about events see the following example:
"// ABAP Objects - Creating your First Local Class - Using Events
ENDCLASS. "main DEFINITION
CLASS main IMPLEMENTATION
CLASS main IMPLEMENTATION.
METHOD set_data.
CONCATENATE 'Instance Attribute value' i_data
INTO attribute SEPARATED BY space.
ENDMETHOD. "set_data
METHOD get_data.
MOVE attribute TO r_data.
ENDMETHOD. "get_data
METHOD set_classdata.
CONCATENATE 'Static Attribute value' i_data
INTO classattribute SEPARATED BY space.
ENDMETHOD. "set_classdata
METHOD get_classdata.
MOVE main=>classattribute TO r_data.
ENDMETHOD. "get_classdata
METHOD print_attribute.
WRITE: i_data, /.
ENDMETHOD. "print_attribute
METHOD print_classattribute.
WRITE: i_data, /.
ENDMETHOD. "print_classattribute
ENDCLASS. "main IMPLEMENTATION
DATA: var type char20.
START-OF-SELECTION.
"// Calling a Static method (note we don't have a object )
"// instead we use the <class name>=><method name>.
main=>set_classdata( 'SDN' ).
var = main=>get_classdata( ).
"// Print the var value
main=>print_classattribute( var ).
DATA: object_reference TYPE REF TO main.
CREATE OBJECT object_reference.
"// - Calling a Instance Method( Note we have to use a object to
"// access the insntace components of class main )
"// - Note we're using the statment "CALL METHOD", see looking for
"// functional & General methods for more informations
CALL METHOD object_reference->set_data( 'BPX' ).
var = object_reference->get_data( ).
object_reference->print_attribute( var ).
Thanks in Advance.
Regards
NaniHi Nani,
try changing your data definition for var from CHAR20 to STRING.
regards,
Peter -
hi,
i need oops programming in abap where in i need only programmin and coding tecnique strictly(dont want theory)means where oops programming needs in reporting,alv and bdc ,i need only programming related material,so if any body having the connecting links or material or objects regarding the above said things kindly reply me here or by sending mail to [email protected]Hi ...
Here i am sending you one Link.....Follow this link and there you can find
theory as well as the sample code examples for every technology in ABAP.
Go for:- http://abapprogramming.blogspot.com/2007/10/oops-abap-2.html.
Regards,
Mandeep.
Note: Plz do not forget to award points if reply is useful. -
Dear all,
Can anybody tell me please which events are being used in ABAP OOPS Programming ? Please , needful reply for same....check these links
http://erpgenie.com/abaptips/content/view/394/61/
http://erpgenie.com/abaptips/content/view/395/61/
Thanks
Bala Duvvuri -
Traffic Signals in ALV Without using oops only for normal Grid Display.
Hi Experts ,
I need to add traffic signals into my normal ALV Grid program without using oops concepts.
Please any one send me full code or provide me one program code without using oops concept for normal ALV Grid .
I searched in many forums but i found most of the programs wriiten using oops concept with ALV's but here my requirement without using oops concept and only normal reuse_alv_grid_display.
Thanks in Advance.
Venky.You can check the below sample code.Traffic light is implemented in it.
REPORT ztest NO STANDARD PAGE HEADING
LINE-SIZE 255 MESSAGE-ID zlqm.
TYPE-POOLS : slis,icon.
TABLES :qals,qave.
INCLUDE : zlqmr002_top, "Global Data Declaration
zlqmr002_selection_screen, "Selection Screen Inputs
zlqmr002_subroutine. "Subroutines
INITIALIZATION
INITIALIZATION.
PERFORM variant_init.
AT SELECTION-SCREEN
AT SELECTION-SCREEN.
Check for Variant existance
PERFORM pai_of_selection_screen.
*Validation for Material
AT SELECTION-SCREEN ON s_matnr.
IF NOT s_matnr IS INITIAL.
SELECT SINGLE matnr
INTO g_matnr
FROM mara
WHERE matnr IN s_matnr.
IF sy-subrc <> 0.
SET CURSOR FIELD 'S_MATNR'.
MESSAGE e000 WITH text-003.
ENDIF.
ENDIF.
*Validation for Plant
AT SELECTION-SCREEN ON s_werk.
IF NOT s_werk IS INITIAL.
SELECT SINGLE werks
INTO g_werk
FROM t001w
WHERE werks IN s_werk.
IF sy-subrc <> 0.
SET CURSOR FIELD 'S_WERK'.
MESSAGE e000 WITH text-004.
ENDIF.
ENDIF.
*Validation for Inspection Type
AT SELECTION-SCREEN ON s_art.
IF NOT s_art IS INITIAL.
SELECT SINGLE art
INTO g_art
FROM tq30
WHERE art IN s_art.
IF sy-subrc <> 0.
SET CURSOR FIELD 'S_ART'.
MESSAGE e000 WITH text-005.
ENDIF.
ENDIF.
*Validation for Code group
AT SELECTION-SCREEN ON s_vcdgrp.
IF NOT s_vcdgrp IS INITIAL.
SELECT SINGLE codegruppe
INTO g_vcdgrp
FROM qpgr
WHERE codegruppe IN s_vcdgrp.
IF sy-subrc <> 0.
SET CURSOR FIELD 'S_VCDGRP'.
MESSAGE e000 WITH text-006.
ENDIF.
ENDIF.
*Validation for Code
AT SELECTION-SCREEN ON s_vcode.
IF NOT s_vcode IS INITIAL.
SELECT SINGLE code
INTO g_vcode
FROM qpcd
WHERE code IN s_vcode.
IF sy-subrc <> 0.
SET CURSOR FIELD 'S_VCODE'.
MESSAGE e000 WITH text-007.
ENDIF.
ENDIF.
Process on value request
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_vcdgrp-low.
PERFORM get_codegroup.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_vcdgrp-high.
PERFORM get_codegroup.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_vcode-low.
PERFORM get_code.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_vcode-high.
PERFORM get_code.
START-OF-SELECTION.
START-OF-SELECTION.
**Selecting data form Database tables
PERFORM select_data TABLES i_out i_out1.
END-OF-SELECTION
END-OF-SELECTION.
**Generate ALV
PERFORM generate_alv.
DATA TYPES
TYPES : BEGIN OF t_qals,
matnr TYPE qals-matnr, "Material
werk TYPE qals-werk, "Plant
mengeneinh TYPE qals-mengeneinh, "UOM
lmenge01 TYPE qals-lmenge01, "Unrestricted qty
lmenge02 TYPE qals-lmenge02, "Scrap qty
lmenge03 TYPE qals-lmenge03, "Sample qty
lmenge04 TYPE qals-lmenge04, "Blocked qty
lmenge05 TYPE qals-lmenge05, "Retain qty
lmenge06 TYPE qals-lmenge06, "Othermat qty
lmenge07 TYPE qals-lmenge07, "RTV qty
lmenge08 TYPE qals-lmenge08, "Exp.scrap qty
prueflos TYPE qals-prueflos, "Inspection lot
art TYPE qals-art, "Inspection type
charg TYPE qals-charg, "Batch
vcode TYPE qave-vcode, "Usage decision
vdatum TYPE qave-vdatum, "Date
qmnum TYPE qmel-qmnum, "Notification
END OF t_qals.
TYPES : BEGIN OF t_out,
icon TYPE icon-id, "Status
matnr TYPE qals-matnr, "Material
werk TYPE qals-werk, "Plant
mengeneinh TYPE qals-mengeneinh, "UOM
vcode TYPE qave-vcode, "Usage decision
mncod(30) TYPE c, "Disposition
lmenge01 TYPE qals-lmenge01, "Unrestricted qty
lmenge02 TYPE qals-lmenge02, "Scrap qty
lmenge03 TYPE qals-lmenge03, "Sample qty
lmenge04 TYPE qals-lmenge04, "Blocked qty
lmenge05 TYPE qals-lmenge05, "Retain qty
lmenge06 TYPE qals-lmenge06, "Othermat qty
lmenge07 TYPE qals-lmenge07, "RTV qty
lmenge08 TYPE qals-lmenge08, "Exp.scrap qty
prueflos TYPE qals-prueflos, "Inspection lot
art TYPE qals-art, "Inspection type
qmnum TYPE qmel-qmnum, "Notification
vdatum TYPE qave-vdatum, "Date
charg TYPE qals-charg, "Batch
END OF t_out.
TYPES : BEGIN OF t_qmsm,
qmnum TYPE qmsm-qmnum,
manum TYPE qmsm-manum,
mncod TYPE qmsm-mncod,
END OF t_qmsm.
TYPES: BEGIN OF t_disp,
qmnum TYPE qmsm-qmnum,
mncod(30) TYPE c,
END OF t_disp.
TYPES: BEGIN OF t_codegrp,
katalogart TYPE qpgt-katalogart,
codegruppe TYPE qpgt-codegruppe,
kurztext TYPE qpgt-kurztext,
END OF t_codegrp.
TYPES: BEGIN OF t_code,
katalogart TYPE qpct-katalogart,
codegruppe TYPE qpct-codegruppe,
code TYPE qpct-code,
version TYPE qpct-version,
kurztext TYPE qpct-kurztext,
END OF t_code.
INTERNAL TABLES
DATA: i_qals TYPE TABLE OF t_qals,
wa_qals LIKE LINE OF i_qals,
i_qmsm TYPE TABLE OF t_qmsm,
wa_qmsm TYPE t_qmsm,
i_disp TYPE TABLE OF t_disp,
wa_disp LIKE LINE OF i_disp,
i_out TYPE TABLE OF t_out,
wa_out TYPE t_out,
i_out1 TYPE TABLE OF t_out,
wa_out1 TYPE t_out,
i_codegrp TYPE TABLE OF t_codegrp,
i_code TYPE TABLE OF t_code,
i_qmsm_tmp TYPE TABLE OF t_qmsm.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
i_layout TYPE slis_layout_alv,
g_repid TYPE sy-repid,
wa_fieldcat TYPE slis_fieldcat_alv.
Global Variables
DATA : g_matnr TYPE matnr,
g_werk TYPE werks,
g_art TYPE qpart,
g_vcdgrp TYPE qvgruppe,
g_vcode TYPE qvcode,
g_red TYPE c,
g_yellow TYPE c,
g_table(6) TYPE c,
g_save(1) TYPE c,
g_exit(1) TYPE c,
g_report TYPE sy-repid,
g_var TYPE disvariant,
g_variant TYPE disvariant.
Constants
CONSTANTS: c_green TYPE icon-id VALUE '@08@',
c_yellow TYPE icon-id VALUE '@09@',
c_red TYPE icon-id VALUE '@0A@'.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_matnr FOR qals-matnr, "Material Number
s_werk FOR qals-werk, "Plant
s_art FOR qals-art, "Inspection Type
s_vcdgrp FOR qave-vcodegrp, "Usage Decision Code Group
s_vcode FOR qave-vcode, "Usage Decision Code
s_vdatum FOR qave-vdatum. "Usage Decision Code Date
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_all RADIOBUTTON GROUP g1 DEFAULT 'X',
p_excp RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-009.
"Variant Selection
PARAMETERS: p_vari TYPE disvariant-variant.
SELECTION-SCREEN END OF BLOCK b3.
*& Form select_data
Select Inspection Details
FORM select_data TABLES p_out STRUCTURE wa_out
p_out1 STRUCTURE wa_out.
DATA:l_mncod(30) TYPE c.
REFRESH : i_qals,i_qmsm,i_qmsm_tmp,i_disp,p_out.
SELECT qalsmatnr qalswerk qals~mengeneinh
qalslmenge01 qalslmenge02 qals~lmenge03
qalslmenge04 qalslmenge05 qals~lmenge06
qalslmenge07 qalslmenge08 qals~prueflos
qalsart qalscharg qave~vcode
qavevdatum qmelqmnum
INTO CORRESPONDING FIELDS OF TABLE i_qals
FROM qals
INNER JOIN qave
ON qalsprueflos = qaveprueflos
INNER JOIN qmel
ON qalsprueflos = qmelprueflos
WHERE qals~matnr IN s_matnr
AND qals~werk IN s_werk
AND qals~art IN s_art
AND qals~stat34 EQ 'X'
AND qave~vcodegrp IN s_vcdgrp
AND qave~vcode IN s_vcode
AND qave~vdatum IN s_vdatum.
IF sy-subrc NE 0.
MESSAGE i000 WITH text-008.
ENDIF.
IF NOT i_qals IS INITIAL.
SELECT qmnum manum mncod INTO TABLE i_qmsm
FROM qmsm
FOR ALL ENTRIES IN i_qals
WHERE qmnum EQ i_qals-qmnum
AND mngrp LIKE 'Q_D%'
AND kzloesch NE 'X'.
ENDIF.
***Concatenation of Disposition Codes
IF NOT i_qmsm IS INITIAL.
i_qmsm_tmp = i_qmsm.
SORT i_qmsm_tmp BY qmnum mncod.
DELETE ADJACENT DUPLICATES FROM i_qmsm_tmp COMPARING qmnum mncod+0(2).
CLEAR wa_qmsm.
LOOP AT i_qmsm_tmp INTO wa_qmsm.
MOVE wa_qmsm-qmnum TO wa_disp-qmnum.
CONCATENATE l_mncod wa_qmsm-mncod+0(2) INTO l_mncod SEPARATED BY space.
AT END OF qmnum.
SHIFT l_mncod LEFT DELETING LEADING space.
MOVE l_mncod TO wa_disp-mncod.
APPEND wa_disp TO i_disp.
CLEAR:wa_disp,l_mncod.
ENDAT.
ENDLOOP.
ENDIF.
***Transfer of data to the output table
LOOP AT i_qals INTO wa_qals.
MOVE-CORRESPONDING wa_qals TO wa_out.
CLEAR wa_disp.
READ TABLE i_disp INTO wa_disp
WITH KEY qmnum = wa_qals-qmnum.
IF sy-subrc EQ 0.
MOVE wa_disp-mncod TO wa_out-mncod.
ENDIF.
PERFORM check_quantity USING wa_qals.
CLEAR wa_qmsm.
LOOP AT i_qmsm INTO wa_qmsm
WHERE qmnum EQ wa_qals-qmnum.
PERFORM check_group USING wa_qals
wa_qmsm.
CLEAR wa_qmsm.
ENDLOOP.
IF g_red NE 'X'.
CLEAR wa_qmsm.
LOOP AT i_qmsm INTO wa_qmsm WHERE qmnum = wa_qals-qmnum
AND mncod0(2) NE wa_qals-vcode0(2).
g_yellow = 'X'.
ENDLOOP.
ENDIF.
IF g_yellow EQ 'X'.
MOVE c_yellow TO wa_out-icon.
ELSEIF g_red EQ 'X'.
MOVE c_red TO wa_out-icon.
ELSE.
MOVE c_green TO wa_out-icon.
ENDIF.
APPEND wa_out TO p_out.
CLEAR:wa_qals,wa_out,g_red,g_yellow.
ENDLOOP.
***IF only exceptions are need to be displayed
IF p_excp EQ 'X'.
CLEAR wa_out.
LOOP AT p_out INTO wa_out WHERE icon EQ c_red.
APPEND wa_out TO p_out1.
ENDLOOP.
ENDIF.
ENDFORM. " select_data
*& Form populate_fieldcat
Populate the Fieldcat Table
FORM populate_fieldcat USING p_table TYPE c.
**status
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'ICON'.
wa_fieldcat-seltext_l = text-010.
wa_fieldcat-outputlen = 15.
wa_fieldcat-icon = 'X'.
APPEND wa_fieldcat TO i_fieldcat.
**Material
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-seltext_l = text-011.
wa_fieldcat-outputlen = 15.
APPEND wa_fieldcat TO i_fieldcat.
**Plant
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'WERK'.
wa_fieldcat-seltext_l = text-012.
wa_fieldcat-outputlen = 7.
APPEND wa_fieldcat TO i_fieldcat.
**Usage Decision
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'VCODE'.
wa_fieldcat-seltext_l = text-013.
wa_fieldcat-outputlen = 15.
APPEND wa_fieldcat TO i_fieldcat.
**Dispositions
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'MNCOD'.
wa_fieldcat-seltext_l = text-014.
wa_fieldcat-outputlen = 18.
APPEND wa_fieldcat TO i_fieldcat.
**UOM
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'MENGENEINH'.
wa_fieldcat-seltext_l = text-015.
wa_fieldcat-outputlen = 18.
APPEND wa_fieldcat TO i_fieldcat.
**Unrestricted Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE01'.
wa_fieldcat-seltext_l = text-016.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Scrap Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE02'.
wa_fieldcat-seltext_l = text-017.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Sample Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE03'.
wa_fieldcat-seltext_l = text-018.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Blocked Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE04'.
wa_fieldcat-seltext_l = text-019.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Retain Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE05'.
wa_fieldcat-seltext_l = text-020.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Other Mat Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE06'.
wa_fieldcat-seltext_l = text-021.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**RTV Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE07'.
wa_fieldcat-seltext_l = text-022.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Exp. Scrap Quantity
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'LMENGE08'.
wa_fieldcat-seltext_l = text-023.
wa_fieldcat-qfieldname = 'MENGENEINH'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Inspection Lot
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'PRUEFLOS'.
wa_fieldcat-seltext_l = text-024.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Inspection Type
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'ART'.
wa_fieldcat-seltext_l = text-025.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Notification
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'QMNUM'.
wa_fieldcat-seltext_l = text-026.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Date
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'VDATUM'.
wa_fieldcat-seltext_l = text-027.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
**Batch
CLEAR wa_fieldcat.
wa_fieldcat-tabname = p_table.
wa_fieldcat-fieldname = 'CHARG'.
wa_fieldcat-seltext_l = text-028.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO i_fieldcat.
ENDFORM. " populate_fieldcat
*& Form check_quantity
To Check the Quantity
FORM check_quantity USING p_qals TYPE t_qals.
IF wa_qals-lmenge01 GT 0.
LOOP AT i_disp TRANSPORTING NO FIELDS
WHERE qmnum EQ wa_qals-qmnum
AND ( mncod CP 'UI'
OR mncod CP 'SR'
OR mncod CP 'ND' ).
ENDLOOP.
IF sy-subrc NE 0.
g_red = 'X'.
ENDIF.
ENDIF.
IF wa_qals-lmenge02 GT 0 AND g_red NE 'X'.
LOOP AT i_disp TRANSPORTING NO FIELDS
WHERE qmnum EQ wa_qals-qmnum
AND ( mncod CP 'SC'
OR mncod CP 'SR' ).
ENDLOOP.
IF sy-subrc NE 0.
g_red = 'X'.
ENDIF.
ENDIF.
IF wa_qals-lmenge04 GT 0 AND g_red NE 'X'.
LOOP AT i_disp TRANSPORTING NO FIELDS
WHERE qmnum EQ wa_qals-qmnum
AND ( mncod CP 'RW'
OR mncod CP 'RD' ).
ENDLOOP.
IF sy-subrc NE 0.
g_red = 'X'.
ENDIF.
ENDIF.
IF wa_qals-lmenge05 GT 0 AND g_red NE 'X'.
LOOP AT i_disp TRANSPORTING NO FIELDS
WHERE qmnum EQ wa_qals-qmnum
AND mncod CP 'R1'.
ENDLOOP.
IF sy-subrc NE 0.
g_red = 'X'.
ENDIF.
ENDIF.
IF wa_qals-lmenge06 GT 0 AND g_red NE 'X'.
LOOP AT i_disp TRANSPORTING NO FIELDS
WHERE qmnum EQ wa_qals-qmnum
AND mncod CP 'RD'.
ENDLOOP.
IF sy-subrc NE 0.
g_red = 'X'.
ENDIF.
ENDIF.
IF wa_qals-lmenge07 GT 0 AND g_red NE 'X'.
LOOP AT i_disp TRANSPORTING NO FIELDS
WHERE qmnum EQ wa_qals-qmnum
AND mncod CP 'RV'.
ENDLOOP.
IF sy-subrc NE 0.
g_red = 'X'.
ENDIF.
ENDIF.
IF wa_qals-lmenge08 GT 0 AND g_red NE 'X'.
LOOP AT i_disp TRANSPORTING NO FIELDS
WHERE qmnum EQ wa_qals-qmnum
AND ( mncod CP 'SC'
OR mncod CP 'SE' ).
ENDLOOP.
IF sy-subrc NE 0.
g_red = 'X'.
ENDIF.
ENDIF.
ENDFORM. " check_quantity
*& Form check_group
To check the Disposition Code
FORM check_group USING p_qals TYPE t_qals
p_qmsm TYPE t_qmsm.
IF p_qmsm-mncod+0(2) EQ 'UI' AND
NOT p_qals-lmenge01 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'RW' AND
NOT p_qals-lmenge04 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'SC' AND
NOT p_qals-lmenge02 GT 0 AND
NOT p_qals-lmenge08 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'SE' AND
NOT p_qals-lmenge08 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'RV' AND
NOT p_qals-lmenge07 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'SR' AND
NOT p_qals-lmenge01 GT 0 AND
NOT p_qals-lmenge02 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'ND' AND
NOT p_qals-lmenge01 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'R1' AND
NOT p_qals-lmenge05 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
IF p_qmsm-mncod+0(2) EQ 'RD' AND
NOT p_qals-lmenge04 GT 0 AND
NOT p_qals-lmenge06 GT 0.
g_red = 'X'.
EXIT.
ENDIF.
ENDFORM. " check_group
*& Form call_alv
Call ALV Grid Display
FORM call_alv TABLES p_out STRUCTURE wa_out.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_pf_status_set = 'PF_STATUS_SET'
i_callback_user_command = 'USER_COMMAND'
is_layout = i_layout
it_fieldcat = i_fieldcat[]
TABLES
t_outtab = p_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " call_alv
*& Form generate_alv
Build ALV
FORM generate_alv .
IF NOT i_out IS INITIAL OR
NOT i_out1 IS INITIAL.
g_repid = sy-repid.
IF p_excp EQ 'X'.
MOVE 'I_OUT1' TO g_table.
ELSEIF p_all EQ 'X'.
MOVE 'I_OUT' TO g_table.
ENDIF.
PERFORM populate_fieldcat USING g_table.
i_layout-zebra = 'X'.
i_layout-colwidth_optimize = 'X'.
IF p_excp = 'X'.
PERFORM call_alv TABLES i_out1.
ELSEIF p_all = 'X'.
PERFORM call_alv TABLES i_out.
ENDIF.
ENDIF.
ENDFORM. " generate_alv
*& Form PF_STATUS_SET
Setting PF Status
FORM pf_status_set USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STATUS1' .
ENDFORM. "PF_STATUS_SET
*& Form USER_COMMAND
User Command Processing
FORM user_command USING r_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN 'UDG'.
IF p_all EQ 'X'.
CLEAR wa_out.
READ TABLE i_out INTO wa_out INDEX rs_selfield-tabindex.
SET PARAMETER ID 'QLS' FIELD wa_out-prueflos.
ELSEIF p_excp EQ 'X'.
CLEAR wa_out1.
READ TABLE i_out1 INTO wa_out1 INDEX rs_selfield-tabindex.
SET PARAMETER ID 'QLS' FIELD wa_out1-prueflos.
ENDIF.
CALL TRANSACTION 'QA13' AND SKIP FIRST SCREEN.
WHEN 'QNF'.
IF p_all EQ 'X'.
CLEAR wa_out.
READ TABLE i_out INTO wa_out INDEX rs_selfield-tabindex.
SET PARAMETER ID 'IQM' FIELD wa_out-qmnum.
ELSEIF p_excp EQ 'X'.
CLEAR wa_out1.
READ TABLE i_out1 INTO wa_out1 INDEX rs_selfield-tabindex.
SET PARAMETER ID 'IQM' FIELD wa_out1-qmnum.
ENDIF.
CALL TRANSACTION 'QM03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM. "USER_COMMAND
*& Form variant_init
Initialize variant
FORM variant_init .
Set Options: save variants userspecific or general
g_save = 'A'.
g_report = sy-repid.
g_var-report = g_report.
Get default variant
g_variant = g_var.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_save
CHANGING
cs_variant = g_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
p_vari = g_variant-variant.
ENDIF.
ENDFORM. " variant_init
*& Form f4_for_variant
F4 help for variant
FORM f4_for_variant .
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = g_var
i_save = g_save
IMPORTING
e_exit = g_exit
es_variant = g_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF g_exit = space.
p_vari = g_variant-variant.
ENDIF.
ENDIF.
ENDFORM. " f4_for_variant
*& Form pai_of_selection_screen
Check existence of Variant
FORM pai_of_selection_screen .
IF NOT p_vari IS INITIAL.
MOVE g_var TO g_variant.
MOVE p_vari TO g_variant-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = g_save
CHANGING
cs_variant = g_variant.
g_var = g_variant.
ELSE.
PERFORM variant_init.
ENDIF.
ENDFORM. " pai_of_selection_screen
*& Form get_codegroup
Get F4 help for Code Group
FORM get_codegroup .
DATA: i_return TYPE TABLE OF ddshretval.
SELECT katalogart codegruppe kurztext FROM qpgt
INTO TABLE i_codegrp
WHERE katalogart EQ '3'
AND sprache EQ sy-langu.
IF sy-subrc EQ 0.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
retfield = 'CODEGRUPPE'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_VCDGRP'
value_org = 'S'
TABLES
value_tab = i_codegrp[]
return_tab = i_return[]
EXCEPTIONS
parameter_error = 1
no_values_found = 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.
ENDIF.
ENDFORM. " get_codegroup
*& Form get_code
Get F4 help for Code
FORM get_code .
DATA: l_field TYPE rsscr-name VALUE 'S_VCDGRP',
l_field_kind TYPE rsscr-kind VALUE 'S',
li_par_values TYPE TABLE OF rsparams,
la_par_values TYPE rsparams,
r_cdgrp TYPE RANGE OF qpct-codegruppe,
la_cdgrp LIKE LINE OF r_cdgrp.
**Get the values entered in the selection screen
PERFORM f4_get_related_values IN PROGRAM rsdbspf4
TABLES li_par_values
USING l_field l_field_kind.
IF NOT li_par_values IS INITIAL.
CLEAR:la_cdgrp,la_par_values.
LOOP AT li_par_values INTO la_par_values.
MOVE-CORRESPONDING la_par_values TO la_cdgrp.
IF la_cdgrp-option IS INITIAL.
MOVE 'EQ' TO la_cdgrp-option.
ENDIF.
APPEND la_cdgrp TO r_cdgrp.
CLEAR la_cdgrp.
ENDLOOP.
ENDIF.
SELECT katalogart codegruppe
code version
kurztext FROM qpct
INTO TABLE i_code
WHERE katalogart EQ '3'
AND codegruppe IN r_cdgrp
AND sprache EQ sy-langu.
IF sy-subrc EQ 0.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
retfield = 'CODE'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_VCODE'
value_org = 'S'
TABLES
value_tab = i_code[]
return_tab =
EXCEPTIONS
parameter_error = 1
no_values_found = 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.
ENDIF.
ENDFORM. " get_code -
Hi all problem in demo OOPS program
I have written small abap-oops program but it is giving error that
The line type of "OBJ" must be compatible with one of the types
"<b>OBJ_RECORD</b>".
Plz help me out.
REPORT zkclass1.
CLASS number1 DEFINITION
CLASS number1 DEFINITION.
PUBLIC SECTION.
METHODS : constructor IMPORTING x1 TYPE i
y1 TYPE i.
METHODS : findsum EXPORTING z TYPE i.
PRIVATE SECTION.
DATA : x TYPE i,
y TYPE i.
ENDCLASS.
CLASS number IMPLEMENTATION
CLASS number1 IMPLEMENTATION.
METHOD constructor.
x = x1.
y = y1.
ENDMETHOD.
METHOD findsum.
z = x + y.
WRITE : / z.
ENDMETHOD.
ENDCLASS.
DATA : obj TYPE REF TO number1.
DATA : z1 TYPE i.
PARAMETERS : s_x1 type i obligatory.
PARAMETERS : s_y1 type i obligatory.
START-OF-SELECTION.
CREATE OBJECT obj EXPORTING x1 = s_x1
y1 = s_y1.
CALL METHOD OF OBJ -> FINDSUM EXPORTING x1 = s_x1
y1 = s_y1.Hi,
Try this way.
* CLASS number1 DEFINITION
CLASS number1 DEFINITION.
PUBLIC SECTION.
METHODS : constructor IMPORTING x1 TYPE i
y1 TYPE i.
METHODS : findsum EXPORTING z TYPE i
y1 type i. "Changed
PRIVATE SECTION.
DATA : x TYPE i,
y TYPE i.
ENDCLASS.
* CLASS number IMPLEMENTATION
CLASS number1 IMPLEMENTATION.
METHOD constructor.
x = x1.
y = y1.
ENDMETHOD.
METHOD findsum.
z = x + y.
y1 = me->y. "Changed
WRITE : / z.
ENDMETHOD.
ENDCLASS.
DATA : obj TYPE REF TO number1.
DATA : z1 TYPE i.
PARAMETERS : s_x1 TYPE i OBLIGATORY.
PARAMETERS : s_y1 TYPE i OBLIGATORY.
START-OF-SELECTION.
CREATE OBJECT obj EXPORTING x1 = s_x1
y1 = s_y1.
"Use This way here.
CALL METHOD obj->findsum IMPORTING z = s_x1
y1 = s_y1.
" Don't use this here.
*CALL METHOD OF OBJ -> FINDSUM EXPORTING x1 = s_x1
*y1 = s_y1. " 'OF' is used for OLE Objects
Regards.
Marcelo Ramos -
Hi,
Im new to oop in as3.0, just finished my first oop application but there is one thing that i don't understand.
If i have movieclips on the stage and i want for ex. the display class to control there position and size then
i need to send it from the document class to the display class using a public method on the display class.
but after developing my first application i got to a point that all of my methods on the display class were public
and i used a lot of repatitive code.... ive been told that i need to avoid public methods and try and keep most of the methods in
the different classes private but the only way to do it is to find a way to pass the movie clip instance to the actual class and control it
and this way most of the methods in the class will be private and the code on the document class will be a lot more cleaner, but i dont really
know how to pass a display object to a different class and use it without passing it to a public method through the document class.I'm relatively new to OOP programming, so please
excuse this newbish question :).
I've been assigned to take over for a co-worker that
has left for vacation. A class that he wrote is
partially implemented, so I'm supposed to finish it
up.
One class in particular, his constructor is empty.That's fine, if that's what makes sense. I'd have one constructor that set all the private data members. Other constructors would call it using sensible defaults where needed.
If the ctor is empty and data members are null, that's very bad. An object should be 100 percent ready to go when you create it.
And to set the instance variables, the user class is
setting them directly, not through accessor methods.So the data members are public? Oh, my. Where's the encapsulation?
This seems like a bad idea, and defeats the whole
purpose of encapsulation. Indeed. Sounds like you know more than your co-worker.
I wanted to re-do some of the code, but are there any
good reasons as to why he might be doing this?If it's a DTO C-struct with no other purpose than ferrying data it might be acceptable. I would say it's not acceptable, but that's my opinion.
Saving some overhead maybe?No, the "overhead" is probably not measurable. I wouldn't optimize such a thing without data that told me it was the bottleneck, and I'd make sure that this "fix" did address the problem before I cast it in stone.
% -
I can't get my registered versions of CS6 Photoshop and Illustrator to run in full mode. I installed CS6 Design Standard online end of June (an upgrade from CS5.5), on my old MacBook Pro. I didn't run the programs then as I was waiting on arrival of new MacBook Pro. I migrated the programs from my old MacBook to the new, and today tried to run those programs for the first time. InDesign work OK (after an initial hiccup) but Illustrator and Photoshop will only run in trial mode, and won't let me save files. My CS6 Design Standard shows with it's registration in my Adobe Account. All seems in order, but Illustrator and Photoshop won't run in registered mode. Can you please help?
Demons1 in the future please only migrate your documents and settings.
Please use the uninstallers to remove your current installation. They are located in the Applications/Utilities/Adobe Installers folder. Once the uninstall is complete you will also want to run the CC Cleaner Tool. You can find more details at Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6 - http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html.
If you need to download a fresh copy of the installation files for Creative Suite 6 you can do so at Download CS6 products. -
Hi...everyone
Please anyone can post me the .vi program for verification of superposition theorem for a resistive circuit. I am using labview 8.5.1 on windows xp platform.
I have a circuit on the NI-ELVIS prototyping board and that i have to interface to the Labview. At least tell me how i can proceed for making this front panel...
plzzzz its urgent
Thank you.......This appears to be a homework problem. If the above link does not answer your question(s) then please post back with specific questions. We will not do your homework for you, but we can provide hints.
-
The JAVA program for "Philosopher Problem"
When I learn the book of "Operating Systems (Design and Implementation)"(written by Andrew S.Tanenbaum), I try to write a program for the "Philosopher Problem" . In the book there is a sample of this problem in C language, and I write it in JAVA. The following is my program, I have tested it. It is correct, but maybe it is not the most efficient way to solve the problem. Can you think out a more efficient program in JAVA to solve this problem?
* Philosopher Eating Problem
* @author mubin
* @version 1.0
public class PhilosopherEating {
//Philosophers' number
private final static int PHER_NUM = 20;
//Philosophers' state
private volatile static int[] pherState = new int[PHER_NUM];
//THINKING
private final static int THINKING = 0;
//HUNGRY
private final static int HUNGRY = 1;
//EATING
private final static int EATING = 2;
//Philosophers thread group
public static Philosopher[] philosophers = new Philosopher[PHER_NUM];
//finish indicator
public volatile static boolean finished =false;
//thread lock
public static Object threadLock = new Object();
public PhilosopherEating() {
* Philosopher class
* @author mubin
* @version 1.0
public static class Philosopher extends Thread{
int pherNo ;
public Philosopher(int no){
this.pherNo = no;
public void run(){
while(!PhilosopherEating.finished){
think();
takeForks(this.pherNo);
eat();
putForks(this.pherNo);
* Thinking
private void think(){
System.out.println("Philosopher"+this.pherNo+"is thinking...");
try {
Thread.sleep( (int)(Math.random()*100));
}catch (Exception ex) {
ex.printStackTrace(System.out);
* Eating
private void eat(){
System.out.println("Philosopher"+this.pherNo+"is eating...");
try {
Thread.sleep( (int)(Math.random()*100));
}catch (Exception ex) {
ex.printStackTrace(System.out);
* Take the fork
private void takeForks(int no){
//System.out.println("takeForks:no:"+no);
synchronized (threadLock) {
pherState[no] = HUNGRY;
testPher(no);
* Put down the fork
private void putForks(int no){
//System.out.println("putForks:no:"+no);
synchronized (threadLock) {
pherState[no] = THINKING;
if( pherState[getLeft()]==HUNGRY ){
philosophers[getLeft()].interrupt();
if( pherState[getRight()]==HUNGRY ){
philosophers[getRight()].interrupt();
* Return the NO. of philosopher who is sitting at the left side of this philosopher
* @return the NO. of the left philosopher
private int getLeft(){
int ret = (pherNo-1)<0? PHER_NUM-1 : (pherNo-1);
return ret;
* Return the NO. of philosopher who is sitting at the right side of this philosopher
* @return the NO. of the right philosopher
private int getRight(){
int ret = (pherNo+1)>=PHER_NUM ? 0 :(pherNo+1);
return ret;
private void testPher(int no){
while(true){
if(pherState[no]==HUNGRY
&&pherState[getLeft()]!=EATING
&&pherState[getRight()]!=EATING) {
pherState[no] = EATING;
//Print and check the philosophers' state
printPher(pherState);
return;
}else{
try {
System.out.println(" Philosopher "+this.pherNo+"is waiting a fork");
threadLock.wait();
}catch (java.lang.InterruptedException ex) {
System.out.println(" Philosopher "+this.pherNo+"is interrupted and woken up to take fork");
//when it is interrupted, do nothing. Just let it continue!
}//end of while(true)
* Print and check the philosophers' state.
* To insure there are no two philosophers sit side by side
* are eating at the same time.
private static void printPher(int[] phers){
System.out.print(" philosophers' state��");
for (int i = 0; i < phers.length; i++) {
System.out.print(" "+phers);
System.out.println("");
for (int i = 0; i < phers.length-1; i++) {
if (phers[i]==EATING && phers[i+1]==EATING){
System.err.println(i+" and "+(i+1)+"two of philosophers sitted side by side are eating at the same time!");
if (phers[0]==EATING && phers[PHER_NUM-1]==EATING){
System.err.println("0 and "+PHER_NUM+"two of philosophers sitted side by side are eating at the same time!");
public static void main(String[] args) {
for (int i = 0; i < PHER_NUM; i++) {
PhilosopherEating.pherState[i] = THINKING;
PhilosopherEating aPhilosopherEating = new PhilosopherEating();
for (int i = 0; i < PHER_NUM; i++) {
philosophers[i] = new Philosopher(i);
philosophers[i].start();
try {
Thread.sleep(30000);
catch (InterruptedException ex) {
ex.printStackTrace(System.out);
//End all the threads of philosophers
PhilosopherEating.finished = true;this problem is about learning how to use threads/synchronise objects etc, the efficiency of the code isn't really an issue, if that's what you mean. As for the efficiency of the solution, it's very hard to tell how efficient it is, but as long as all the philosphers get to eat there's no problem. I haven't really scrutized your code, but I'm not sure that you have a deadlock free solution: as long as it is possible for all the phils to pick up one fork at the same time there's a problem, and it seems from your code that each philosopher will pick up "his" fork. Again, I could be wrong, I haven't really looked. If you haven't come up with a solution, try drawing it on paper and working it out, or if you're lazy a quick google will probably give you the answer, but I'm pretty sure nobody here will :)
-
Need standrad program for vendor aging report
Hi
Need standrad program for vendor aging report.
Please reply me only standrad programs.
Point are sure.
Regards,
kumarHi Pankaj
sorry to say that this is not my required program.
I need vendor aging report like s_alr_87012178 tc leads to customer aging report.
Thanks for your effort.
points are awarded.
Regards,
kumar -
Standard IDOCS, Programs for posting FI & bank related data.
Hi,
(1)Are there any idocs available for posting FI documents, Vendor master?
(2)Are there any outbound idocs, programs for sending data to banks. EG:positive pay etc?
Kindly reply to these questions. Correct answer will be awarded points.
Regards,
Akshaya.Hi,
There is message type BANK_CREATE for posting the FI related Bank details. Using the change pointers you can trigger the idocs for posting the bank related data.
Regards,
Uday -
Standard print program for fi invoice smartform printing
Hi friend,
Is there any standard print program available for printing FI related invoice .
I want print program for printing smartforms.
I want to know any method for searching the standard print program for printing smartform in Fi module.
Thanks & Regards,
SathishHi,
FI related Forms will be configure in SPRO.
Goto SPRO and FI related applivcation.
There you will find the related forms and programs. -
Program for creating a model is locked by User
Hi Guys,
We have created a process chain to create the Integration Model and to activate the Integration Model using this prg RIMODGEN. So, This prg we have created variants for different location wise. This process chain contains 13 processes For each location, which is running in parallel. Some time we are getting the error message " Program for creating a model is locked by User
RegardsDear Pullaiah,
Locking happens if there is any overlap of models or duplicate scheduling of jobs with same variant.
See include LCIFIF01
CALL FUNCTION 'ENQUEUE_ECIF_IMOD'
EXPORTING
mode_cif_imod = 'E'
modelname = i_modid
logsys = i_logsys
apoapp = i_appl
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
So this means for you, you get the lockentry if the modelname, logsys and apoapp is the same. So please check again your variants if there is one with the same integrationmodels.
This can be the only reason we you get here this entry in your joblog.
Regards,
Tibor
Maybe you are looking for
-
Map Filename to field within mapping
I have a requirement to map the filename to a field in the header of a file to file scenario and then create a new filename based upon the fields of the data structure of the header record. I am comfortable using the variable substituion to either ma
-
both me and my sister do not have all the options available to us on ichat and we both want to use the video chat help please were both new to the mac worlds. thanks!
-
What Are The Benefits Of Registrati
CAn Someone tell me what the benefits of registering your zen v plus?
-
How to drop a temp table in bi publisher
Hi We are using Bi publisher 10g with sybase and we have a query which uses temporary table Below is the sample T-sql query Ex : Select column1,column2 into temp_table from table1 Select column1 from temp_table drop temp_table We are not able to drop
-
Fixing the loupe tool position while making adjustments
I haven't found a way to do this - maybe it's an enhancement - but just in case .... Is there a way to fix the loupe in position while making adjustments (ex. noise and sharpness)? I'd like the loupe to display real-time the results of the adjustment