0% found this document useful (0 votes)
51 views23 pages

Sap PS Prog Adjustposid

The document outlines a correction instruction for the software component S4CORE, detailing the changes and objects not contained in the standard SAP system. It includes the definition and implementation of various classes related to handling edit masks and external identifiers, along with methods for validation, error handling, and database interactions. The document serves as a technical reference for developers working with SAP systems and managing data integrity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views23 pages

Sap PS Prog Adjustposid

The document outlines a correction instruction for the software component S4CORE, detailing the changes and objects not contained in the standard SAP system. It includes the definition and implementation of various classes related to handling edit masks and external identifiers, along with methods for validation, error handling, and database interactions. The document serves as a technical reference for developers working with SAP systems and managing data integrity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 23

*$*$----------------------------------------------------------------$*$*

*$ Correction Inst. 0020751259 0000170475 $*


*$--------------------------------------------------------------------$*
*$ Valid for : $*
*$ Software Component S4CORE $*
*$ Release 100 All Support Package Levels $*
*$ Release 101 All Support Package Levels $*
*$ Release 102 All Support Package Levels $*
*$ Release 103 All Support Package Levels $*
*$ Release 104 All Support Package Levels $*
*$ Release 105 All Support Package Levels $*
*$ Release 106 All Support Package Levels $*
*$ Release 107 All Support Package Levels $*
*$ Release 108 All Support Package Levels $*
*$--------------------------------------------------------------------$*
*$ Changes/Objects Not Contained in Standard SAP System $*
*$*$----------------------------------------------------------------$*$*
*&--------------------------------------------------------------------*
*& Object REPS ZZADJUSTPOSID
*& Object Header PROG ZZADJUSTPOSID
*&--------------------------------------------------------------------*
*& REPORT ZZADJUSTPOSID
*&--------------------------------------------------------------------*
*>>>> START OF INSERTION <<<<
report zzadjustposid.
types:
t_msg(80) type c,

ps_edmask type tcjed,

ps_version_number(12) type c, " vsproj_cn-vnsmr


ps_number_extern(24) type c, " proj-pspid, prps-posid
ps_number_intern(8) type c, " proj-pspnr, prps-pspnr

begin of t_dataset,
ver type ps_version_number,
int type ps_number_intern,
ext type ps_number_extern,
end of t_dataset,

begin of t_stat_msg,
icon like icon-id,
message type t_msg,
end of t_stat_msg.

*---------------------------------------------------------------------*
* CLASS edmask_base DEFINITION
* abstract base class - can analyse and fix mismatches between
* database and edit mask
*
* implement update_db, fetch_data, check_db, get_classid for
* concrete implementations
*---------------------------------------------------------------------*
class edmask_base definition abstract.
public section.
data:
checkmasks type tcjed-proid,
lt_problem_masks type table of ps_edmask,
squeezemode type c,
testmode type c,
dialogmode type c,

datasets type i, "no of elemens processed


dialogcount type i, "dialog needed x times
okcount type i, "no problem here
errorcount type i, "mismatch

lv_errorflag type c,
lv_lasterror type t_msg.

methods:
constructor,
limit importing mask type tcjed-proid,

work,
headline abstract,
add_diag importing newmsg type t_msg
msgtype type i,
show_diag,
show_error.

protected section.
data:
con_green type icon-id,
con_yellow type icon-id,
con_red type icon-id,

lt_data type table of t_dataset,


lt_diag type standard table of t_stat_msg,
lt_tcjed type standard table of ps_edmask.

methods:
fix importing object type t_dataset
new_external_id type ps_number_extern
exporting rcode type sy-subrc,

get_valid_number importing wrongid type ps_number_extern


version type ps_version_number
editmask type tcjed
exporting newid type ps_number_extern
rval type sy-subrc,

set_error importing errormsg type t_msg,

* check wether entry is valid


isvalid importing external_id type ps_number_extern
exporting output type ps_number_extern
rcode type sy-subrc,

squeeze importing external_id type ps_number_extern


mask type ps_edmask
exporting result type ps_number_extern
unedited type ps_number_extern
rcode type sy-subrc,
* abstract methods
* change entry on database NOTE: has to check wether in testmode
update_db abstract
importing internal_id type ps_number_intern
version type ps_version_number
new_external_id type ps_number_extern
exporting rval type sy-subrc,

* fetch data from database table into table lt_data


fetch_data abstract
importing mask type ps_edmask,

* check wether external number exists on database


check_db abstract
importing external_id type ps_number_extern
version type ps_version_number
exporting rval type sy-subrc,

* get name of element in use


get_classid abstract
exporting classid type t_msg.
endclass.

*---------------------------------------------------------------------*
* CLASS edmask_pdef DEFINITION
*---------------------------------------------------------------------*
class edmask_pdef definition inheriting from edmask_base.
public section.
methods:
headline redefinition.

protected section.
methods:
get_classid redefinition,
check_db redefinition,
fetch_data redefinition,
update_db redefinition.
endclass.

*---------------------------------------------------------------------*
* CLASS edmask_wbs DEFINITION
*---------------------------------------------------------------------*
class edmask_wbs definition inheriting from edmask_base.
public section.
methods:
headline redefinition.

protected section.
methods:
get_classid redefinition,
check_db redefinition,
fetch_data redefinition,
update_db redefinition.
endclass.

*---------------------------------------------------------------------*
* CLASS edmask_spdef DEFINITION
*---------------------------------------------------------------------*
class edmask_spdef definition inheriting from edmask_base.
public section.
methods:
headline redefinition.

protected section.
methods:
get_classid redefinition,
check_db redefinition,
fetch_data redefinition,
update_db redefinition.
endclass.

*---------------------------------------------------------------------*
* CLASS edmask_std_wbs DEFINITION
*---------------------------------------------------------------------*
class edmask_std_wbs definition inheriting from edmask_base.
public section.
methods:
headline redefinition.

protected section.
methods:
get_classid redefinition,
check_db redefinition,
fetch_data redefinition,
update_db redefinition.
endclass.

*---------------------------------------------------------------------*
* CLASS edmask_sim_pdef DEFINITION
*---------------------------------------------------------------------*
class edmask_sim_pdef definition inheriting from edmask_base.
public section.
methods:
headline redefinition.

protected section.
methods:
get_classid redefinition,
check_db redefinition,
fetch_data redefinition,
update_db redefinition.
endclass.

*---------------------------------------------------------------------*
* CLASS edmask_sim_wbs DEFINITION
*---------------------------------------------------------------------*
class edmask_sim_wbs definition inheriting from edmask_base.
public section.
methods:
headline redefinition.

protected section.
methods:
get_classid redefinition,
check_db redefinition,
fetch_data redefinition,
update_db redefinition.
endclass.

*---------------------------------------------------------------------*
* CLASS edmask_base IMPLEMENTATION
*---------------------------------------------------------------------*
class edmask_base implementation.
*---------------------------------------------------------------------*
* CONSTRUCTOR edmask_base
*---------------------------------------------------------------------*
method constructor.
* fetch icons
select single id from icon into con_green
where name = 'ICON_LED_GREEN'.
select single id from icon into con_yellow
where name = 'ICON_LED_YELLOW'.
select single id from icon into con_red
where name = 'ICON_LED_RED'.

* fetch all edit masks


select * from tcjed into table lt_tcjed.

if lt_tcjed[] is initial.
call method set_error exporting errormsg = 'No edit masks found.'.
exit.
endif.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_base.squeeze
*---------------------------------------------------------------------*
* put external into edit mask, no matter what
*---------------------------------------------------------------------*
method squeeze.
constants:
con_char(26) type c value 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
con_num(10) type c value '0123456789'.
data:
lv_rcode type i,
lv_id_pos type i,
lv_mask_pos type i,
lv_output type ps_number_extern,
lv_id type ps_number_extern,
lv_len type i,
lv_masklen type i,
lv_current_mask type c,
lv_current_id type c.

lv_len = strlen( mask-proid ).


lv_id = external_id.
shift lv_id left by lv_len places.

lv_output = mask-proid.
lv_mask_pos = 0.

lv_masklen = strlen( mask-posid ).


lv_len = strlen( lv_id ).
do lv_len times.
lv_current_id = lv_id+lv_id_pos(1).
lv_current_mask = mask-posid+lv_mask_pos(1).

* NUMBER
if con_num ca lv_current_id.
while lv_current_mask ne 'X' and lv_current_mask ne '0'.
concatenate lv_output lv_current_mask into lv_output.
add 1 to lv_mask_pos.
if not lv_mask_pos < lv_masklen. exit. endif.
lv_current_mask = mask-posid+lv_mask_pos(1).
endwhile.
if lv_current_mask eq 'X' or lv_current_mask eq '0'.
concatenate lv_output lv_current_id into lv_output.
add 1 to lv_mask_pos.
if not lv_mask_pos < lv_masklen. lv_rcode = 1. endif.
else.
lv_rcode = 1.
endif.
* CHAR
elseif con_char ca lv_current_id.
while lv_current_mask ne 'X'.
concatenate lv_output lv_current_mask into lv_output.
add 1 to lv_mask_pos.
if not lv_mask_pos < lv_masklen. exit. endif.
lv_current_mask = mask-posid+lv_mask_pos(1).
endwhile.
if lv_current_mask eq 'X'.
concatenate lv_output lv_current_id into lv_output.
add 1 to lv_mask_pos.
if not lv_mask_pos <= lv_masklen. lv_rcode = 1. endif.
else.
lv_rcode = 1.
endif.
endif.
check lv_rcode is initial.
add 1 to lv_id_pos.
enddo.
result = lv_output.
rcode = lv_rcode.

* produced edited number, return also unedited


if rcode is initial.
call function 'CJPN_PROJEKTNUMMER_UNEDIT'
exporting
input = lv_output
importing
output = unedited
exceptions
error_message = 1.
endif.
endmethod. "squeeze

*---------------------------------------------------------------------*
* METHOD edmask_base.limit
*---------------------------------------------------------------------*
* limit work to some edit masks
*---------------------------------------------------------------------*
method limit.
* fetch edit masks
select * from tcjed into table lt_tcjed where proid = mask.
if lt_tcjed[] is initial.
call method set_error exporting errormsg = 'No edit masks found.'.
exit.
endif.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_base.show_error
*---------------------------------------------------------------------*
* print out last error message
*---------------------------------------------------------------------*
method show_error.
if lv_errorflag is initial. exit. endif.
format color col_negative.
write: lv_lasterror.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_base.show_diag
*---------------------------------------------------------------------*
* show diagnostic messags
*---------------------------------------------------------------------*
method show_diag.
field-symbols: <fs_msg> type t_stat_msg.
loop at lt_diag assigning <fs_msg>.
write: / <fs_msg>-icon as icon , <fs_msg>-message.
endloop.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_base.set_error
*---------------------------------------------------------------------*
* set internal error message+flag
*---------------------------------------------------------------------*
method set_error.
lv_errorflag = 'X'.
lv_lasterror = errormsg.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_base.add diag
*---------------------------------------------------------------------*
* add diag message
*---------------------------------------------------------------------*
method add_diag.
data:
newbie type t_stat_msg.
newbie-message = newmsg.
if msgtype = 0.
newbie-icon = con_green.
elseif msgtype = 1.
newbie-icon = con_yellow.
elseif msgtype = 2.
newbie-icon = con_red.
endif.

append newbie to lt_diag.


endmethod.
*---------------------------------------------------------------------*
* METHOD edmask_base.isvalid
*---------------------------------------------------------------------*
* check for valid external number
*---------------------------------------------------------------------*
method isvalid.
data:
lv_result type ps_number_extern,
lv_rcode type i.

* number is stored unedited on DB -> force unedit


call function 'CJPN_PROJEKTNUMMER_UNEDIT'
exporting
input = external_id
importing
output = lv_result
rcode = lv_rcode
exceptions
error_message = 1.
if not sy-subrc is initial. lv_rcode = 2. endif.
output = lv_result.
rcode = lv_rcode.
endmethod.

*---------------------------------------------------------------------*
* METHOD get_valid_number
*---------------------------------------------------------------------*
* get a pspid from the user
*---------------------------------------------------------------------*
method get_valid_number.
data:
lv_dummy type proj-pspid,
lv_ext type ps_number_extern,
lv_ext_user type ps_number_extern,
lv_rcode type sy-subrc,
lv_editmask(50) type c,
lv_answerstring type spop-varvalue1,
lv_answer type c,
lv_exit type c,
lv_helpstring(50) type c,
lv_classid type t_msg.

concatenate editmask-proid editmask-posid into lv_editmask.

call method get_classid importing classid = lv_classid.

while lv_exit is initial.


if version is initial.
concatenate lv_classid wrongid
into lv_helpstring separated by space.
else.
concatenate lv_classid 'Version' version 'of' wrongid
into lv_helpstring separated by space.
endif.

call function 'POPUP_TO_GET_ONE_VALUE'


EXPORTING
textline1 = lv_helpstring
textline2 = 'cannot be auto converted using'
textline3 = lv_editmask
titel = 'Manual number adjustment'
valuelength = 24
IMPORTING
answer = lv_answer
value1 = lv_answerstring.

if lv_answer eq 'A'.
* Cancel: skip this one
lv_exit = 'X'.
rval = 1.
elseif not lv_answerstring is initial.
* check wether user gave us valid input
lv_ext_user = lv_answerstring(24).
call method isvalid exporting external_id = lv_ext_user
importing output = lv_ext
rcode = lv_rcode.

if not lv_rcode is initial.


message i001(cj)
with 'Number does not fit in used edit mask.'.
else.
* check wether Number already exists on database
call method check_db exporting external_id = lv_ext
version = version
importing rval = lv_rcode.

if not lv_rcode is initial.


message i001(cj)
with 'Number does already exist on DB.'.
else.
lv_exit = 'X'.
newid = lv_ext.
rval = 0.
endif.
endif.
else.
message i001(cj) with 'Enter a valid number.'.
endif.
endwhile.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_base.fix
*---------------------------------------------------------------------*
* try to rename object on database
* return 0 if renamed
* 1 if not renamed because we're in testmode
* 2 if not renamed due to db error
* 3 if not renamed because new entry exists
*---------------------------------------------------------------------*
method fix.
data:
lv_rcode type sy-subrc.

* check wether new entry already exists on db


call method check_db exporting external_id = new_external_id
version = object-ver
importing rval = lv_rcode.

if not lv_rcode is initial.


* this string already exists on database
* -> adjustment not possible
lv_rcode = 3.
else.
* change database
call method update_db
exporting internal_id = object-int
version = object-ver
new_external_id = new_external_id
importing rval = lv_rcode.
endif.
rcode = lv_rcode.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_base.work
*---------------------------------------------------------------------*
* do the actual work
*---------------------------------------------------------------------*
method work.
field-symbols:
<fs_data> type t_dataset,
<fs_tcjed> type ps_edmask.

data:
lv_msg type t_msg,
lv_msg_type type i,
lv_rcode type sy-subrc,
lv_helpstring(50) type c,
lv_ext type ps_number_extern,
lv_first_error type c.

* loop over all selected edit masks


loop at lt_tcjed assigning <fs_tcjed>.
* fill lt_data
call method fetch_data exporting mask = <fs_tcjed>.

clear lv_first_error.
loop at lt_data assigning <fs_data>.
add 1 to datasets.
clear: lv_ext, lv_rcode.

call method isvalid exporting external_id = <fs_data>-ext


importing output = lv_ext
rcode = lv_rcode.

* if representation on DB differs from unedited or rcode > 0


* -> error
if ( <fs_data>-ext ne lv_ext ) or ( not lv_rcode is initial ).
if lv_first_error is initial.
append <fs_tcjed> to lt_problem_masks.
endif.
lv_msg_type = 2.
add 1 to errorcount.

concatenate <fs_data>-ext
'does not match' <fs_tcjed>-proid <fs_tcjed>-posid
into lv_msg separated by space.

if ( <fs_data>-ext ne lv_ext ) and ( lv_rcode is initial ).


* representation on DB differs from unedited and rcode = 0
* -> unediting was possible
call method fix exporting object = <fs_data>
new_external_id = lv_ext
importing rcode = lv_rcode.
case lv_rcode.
when 0.
concatenate lv_msg 'unedited to' lv_ext
into lv_msg separated by space.
lv_msg_type = 0.
when 1.
concatenate lv_msg 'unediting possible to' lv_ext
into lv_msg separated by space.
lv_msg_type = 1.
when 2.
concatenate lv_msg 'database error renaming to' lv_ext
into lv_msg separated by space.
lv_msg_type = 2.
when 3.
concatenate lv_msg 'unedited entry already exists'
lv_ext into lv_msg separated by space.
lv_msg_type = 2.
endcase.
else.
* unediting was not possible
if not squeezemode is initial.
* try to squeeze into edit mask
call method squeeze
exporting external_id = <fs_data>-ext
mask = <fs_tcjed>
importing result = <fs_data>-ext
unedited = lv_ext
rcode = lv_rcode.

if lv_rcode is initial.
call method fix
exporting object = <fs_data>
new_external_id = lv_ext
importing rcode = lv_rcode.

case lv_rcode.
when 0.
concatenate lv_msg 'renamed to' <fs_data>-ext
into lv_msg separated by space.
lv_msg_type = 0.
when 1.
concatenate lv_msg 'renaming possible to'
<fs_data>-ext into lv_msg separated by space.
lv_msg_type = 1.
lv_rcode = 0.
when 2.
concatenate lv_msg 'database error renaming to'
<fs_data>-ext into lv_msg separated by space.
lv_msg_type = 2.
when 3.
concatenate lv_msg 'renamed entry already exists'
<fs_data>-ext into lv_msg separated by space.
lv_msg_type = 2.
endcase.
endif.
endif.

* DIALOG adjust
if not lv_rcode is initial.
add 1 to dialogcount.
if testmode is initial and not dialogmode is initial.
call method get_valid_number
exporting
wrongid = <fs_data>-ext
version = <fs_data>-ver
editmask = <fs_tcjed>
importing
newid = lv_ext
rval = lv_rcode.

if lv_rcode = 0.
concatenate lv_msg ', new id is ' lv_ext into lv_msg
separated by space.
call method update_db
exporting internal_id = <fs_data>-int
version = <fs_data>-ver
new_external_id = lv_ext
importing rval = lv_rcode.

lv_msg_type = lv_rcode.
if lv_rcode = 2.
concatenate lv_msg 'database error' into lv_msg
separated by space.
endif.
else.
concatenate lv_msg ', dialog aborted' into lv_msg
separated by space.
lv_msg_type = 2.
endif.
else.
* unediting was not possible
concatenate lv_msg
'dialog neccessary'
into lv_msg separated by space.
endif.
endif.
endif.
call method add_diag exporting newmsg = lv_msg
msgtype = lv_msg_type.
else.
add 1 to okcount.
endif.
endloop.
endloop.
endmethod.
endclass. " edmask base

*---------------------------------------------------------------------*
* CLASS edmask_pdef IMPLEMENTATION
*---------------------------------------------------------------------*
class edmask_pdef implementation.

method headline.
write: / 'project definition'.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_pdef.update_db
*---------------------------------------------------------------------*
* update PROJ if NOT in testmode
*---------------------------------------------------------------------*
method update_db.
data:
newid type proj-pspid,
oldid type proj-pspnr.

if testmode is initial.
newid = new_external_id.
oldid = internal_id.

update proj set pspid = newid where pspnr = oldid.


if sy-subrc is initial. rval = 0.
else. rval = 2. endif.
else.
* return 1 if in testmode (done nothing)
rval = 1.
endif.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_pdef.fetch_data
*---------------------------------------------------------------------*
* select from proj into lt_data
*---------------------------------------------------------------------*
method fetch_data.
data:
wa_proj type proj,
ls_data type t_dataset,
lv_searchstring(24) type c.

clear: lt_data.

concatenate mask-proid '%' into lv_searchstring.


select pspid pspnr from proj
into corresponding fields of wa_proj
where pspid like lv_searchstring.

ls_data-int = wa_proj-pspnr.
ls_data-ext = wa_proj-pspid.
append ls_data to lt_data.
endselect.
endmethod.
**---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* METHOD edmask_pdef.check_db
*---------------------------------------------------------------------*
* check database for existing entries
*---------------------------------------------------------------------*
method check_db.
data:
lv_dummy type projs-pspid.
select single pspid from proj into lv_dummy
where pspid = external_id.
if sy-subrc is initial. rval = 1.
else. rval = 0. endif.
endmethod.

method get_classid.
classid = 'Project definition'.
endmethod.
endclass. " edmask_pdef

*---------------------------------------------------------------------*
* CLASS edmask_sim_pdef IMPLEMENTATION
*---------------------------------------------------------------------*
class edmask_sim_pdef implementation.

method headline.
write: / 'project definition of simulation/version'.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_sim_pdef.update_db
*---------------------------------------------------------------------*
* update VSPROJ_CN if NOT in testmode
*---------------------------------------------------------------------*
method update_db.
data:
newid type vsproj_cn-pspid,
oldid type vsproj_cn-pspnr.

if testmode is initial.
newid = new_external_id.
oldid = internal_id.

update vsproj_cn set pspid = newid


where pspnr = oldid and vsnmr = version.
if sy-subrc is initial. rval = 0.
else. rval = 2. endif.
else.
* return 1 if in testmode (done nothing)
rval = 1.
endif.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_sim_pdef.fetch_data
*---------------------------------------------------------------------*
* select from vsproj_cn into lt_data
*---------------------------------------------------------------------*
method fetch_data.
data:
wa_vsproj type vsproj_cn,
ls_data type t_dataset,
lv_searchstring(24) type c.

clear: lt_data.

concatenate mask-proid '%' into lv_searchstring.


select vsnmr pspid pspnr from vsproj_cn
into corresponding fields of wa_vsproj
where pspid like lv_searchstring.

ls_data-ver = wa_vsproj-vsnmr.
ls_data-int = wa_vsproj-pspnr.
ls_data-ext = wa_vsproj-pspid.
append ls_data to lt_data.
endselect.
endmethod.

*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* METHOD edmask_sim_pdef.check_db
*---------------------------------------------------------------------*
* check database for existing entries
*---------------------------------------------------------------------*
method check_db.
data:
lv_dummy type vsproj_cn.
select single pspid from vsproj_cn into lv_dummy
where pspid = external_id and vsnmr = version.
if sy-subrc is initial. rval = 1.
else. rval = 0. endif.
endmethod.

method get_classid.
classid = 'Simulation project definition'.
endmethod.
endclass. " edmask_sim_pdef

*---------------------------------------------------------------------*
* CLASS edmask_spdef IMPLEMENTATION
*---------------------------------------------------------------------*
class edmask_spdef implementation.

method headline.
write: / 'standard project definition'.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_spdef.update_db
*---------------------------------------------------------------------*
* update PROJS if NOT in testmode
*---------------------------------------------------------------------*
method update_db.
data:
newid type projs-pspid,
oldid type projs-pspnr.
if testmode is initial.
newid = new_external_id.
oldid = internal_id.

update projs set pspid = newid where pspnr = oldid.


if sy-subrc is initial. rval = 0.
else. rval = 2. endif.
else.
* return 1 if in testmode (done nothing)
rval = 1.
endif.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_spdef.fetch_data
*---------------------------------------------------------------------*
* select from projs into lt_data
*---------------------------------------------------------------------*
method fetch_data.
data:
wa_projs type projs,
ls_data type t_dataset,
lv_searchstring(24) type c.

clear: lt_data.

concatenate mask-proid '%' into lv_searchstring.


select pspid pspnr from projs
into corresponding fields of wa_projs
where pspid like lv_searchstring.

ls_data-int = wa_projs-pspnr.
ls_data-ext = wa_projs-pspid.
append ls_data to lt_data.
endselect.
endmethod.

*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* METHOD edmask_spdef.check_db
*---------------------------------------------------------------------*
* check database for existing entries
*---------------------------------------------------------------------*
method check_db.
data:
lv_dummy type projs-pspid.
select single pspid from projs into lv_dummy
where pspid = external_id.
if sy-subrc is initial. rval = 1.
else. rval = 0. endif.
endmethod.

method get_classid.
classid = 'Standard project definition'.
endmethod.
endclass. " edmask_sim_pdef

*---------------------------------------------------------------------*
* CLASS edmask_wbs IMPLEMENTATION
*---------------------------------------------------------------------*
class edmask_wbs implementation.
*---------------------------------------------------------------------*
* METHOD edmask_wbs.update_db
*---------------------------------------------------------------------*
* update PRPS if NOT in testmode
*---------------------------------------------------------------------*
method update_db.
data:
newid type prps-posid,
oldid type prps-pspnr.

if testmode is initial.
newid = new_external_id.
oldid = internal_id.

update prps set posid = newid


where pspnr = oldid.
if sy-subrc is initial. rval = 0.
else. rval = 2. endif.
else.
* return 1 if in testmode (done nothing)
rval = 1.
endif.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_wbs.fetch_data
*---------------------------------------------------------------------*
* select from prps into lt_data
*---------------------------------------------------------------------*
method fetch_data.
data:
wa_prps type prps,
ls_data type t_dataset,
lv_searchstring(24) type c.

clear: lt_data.

concatenate mask-proid '%' into lv_searchstring.

select posid pspnr from prps


into corresponding fields of wa_prps
where posid like lv_searchstring.

ls_data-int = wa_prps-pspnr.
ls_data-ext = wa_prps-posid.
append ls_data to lt_data.
endselect.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_wbs.check_db
*---------------------------------------------------------------------*
* check database for existing entries
* return: 0 if free (entry does not exist), 1 otherwise
*---------------------------------------------------------------------*
method check_db.
data:
lv_dummy type prps-posid.
select single posid from prps into lv_dummy
where posid = external_id.
if sy-subrc is initial. rval = 1.
else. rval = 0. endif.
endmethod.

method get_classid.
classid = 'WBS-Element'.
endmethod.

method headline.
write: / 'wbs element'.
endmethod.
endclass. " edmask_wbs

*---------------------------------------------------------------------*
* CLASS edmask_std_wbs IMPLEMENTATION
*---------------------------------------------------------------------*
class edmask_std_wbs implementation.
*---------------------------------------------------------------------*
* METHOD edmask_std_wbs.update_db
*---------------------------------------------------------------------*
* update PRPSS if NOT in testmode
*---------------------------------------------------------------------*
method update_db.
data:
newid type prpss-posid,
oldid type prpss-pspnr.

if testmode is initial.
newid = new_external_id.
oldid = internal_id.

update prpss set posid = newid


where pspnr = oldid.
if sy-subrc is initial. rval = 0.
else. rval = 2. endif.
else.
* return 1 if in testmode (done nothing)
rval = 1.
endif.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_std_wbs.fetch_data
*---------------------------------------------------------------------*
* select from prpss into lt_data
*---------------------------------------------------------------------*
method fetch_data.
data:
wa_prpss type prpss,
ls_data type t_dataset,
lv_searchstring(24) type c.

clear: lt_data.

concatenate mask-proid '%' into lv_searchstring.


select posid pspnr from prpss
into corresponding fields of wa_prpss
where posid like lv_searchstring.

ls_data-int = wa_prpss-pspnr.
ls_data-ext = wa_prpss-posid.
append ls_data to lt_data.
endselect.
endmethod.
*---------------------------------------------------------------------*
* METHOD edmask_wbs.check_db
*---------------------------------------------------------------------*
* check database for existing entries
* return: 0 if free (entry does not exist), 1 otherwise
*---------------------------------------------------------------------*
method check_db.
data:
lv_dummy type prpss-posid.
select single posid from prpss into lv_dummy
where posid = external_id.
if sy-subrc is initial. rval = 1.
else. rval = 0. endif.
endmethod.

method get_classid.
classid = 'Standard WBS-Element'.
endmethod.

method headline.
write: / 'standard wbs element'.
endmethod.
endclass. " edmask_std_wbs

*---------------------------------------------------------------------*
* CLASS edmask_sim_wbs IMPLEMENTATION
*---------------------------------------------------------------------*
class edmask_sim_wbs implementation.
*---------------------------------------------------------------------*
* METHOD edmask_sim_wbs.update_db
*---------------------------------------------------------------------*
* update VSPRPS_CN if NOT in testmode
*---------------------------------------------------------------------*
method update_db.
data:
newid type vsprps_cn-posid,
oldid type vsprps_cn-pspnr.

if testmode is initial.
newid = new_external_id.
oldid = internal_id.

update vsprps_cn set posid = newid


where pspnr = oldid and vsnmr = version.
if sy-subrc is initial. rval = 0.
else. rval = 2. endif.
else.
* return 1 if in testmode (done nothing)
rval = 1.
endif.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_sim_wbs.fetch_data
*---------------------------------------------------------------------*
* select from vsprps_cn into lt_data
*---------------------------------------------------------------------*
method fetch_data.
data:
wa_vsprps type vsprps_cn,
ls_data type t_dataset,
lv_searchstring(24) type c.

clear: lt_data.

concatenate mask-proid '%' into lv_searchstring.

select posid pspnr vsnmr from vsprps_cn


into corresponding fields of wa_vsprps
where posid like lv_searchstring.

ls_data-ver = wa_vsprps-vsnmr.
ls_data-int = wa_vsprps-pspnr.
ls_data-ext = wa_vsprps-posid.
append ls_data to lt_data.
endselect.
endmethod.

*---------------------------------------------------------------------*
* METHOD edmask_sim_wbs.check_db
*---------------------------------------------------------------------*
* check database for existing entries
* return: 0 if free (entry does not exist), 1 otherwise
*---------------------------------------------------------------------*
method check_db.
data:
lv_dummy type vsprps_cn-posid.
select single posid from vsprps_cn into lv_dummy
where posid = external_id and vsnmr = version.
if sy-subrc is initial. rval = 1.
else. rval = 0. endif.
endmethod.

method get_classid.
classid = 'SIM-WBS-Element'.
endmethod.

method headline.
write: / 'wbs element of project version/simulation'.
endmethod.
endclass. " edmask_sim_wbs

*---------------------------------------------------------------------*
* INITIALIZATION
*---------------------------------------------------------------------*
initialization.
tables: tcjed.

data:
gt_problem_masks type table of tcjed,
gr_check type ref to edmask_base.

field-symbols:
<fs_tcjed> type tcjed.

selection-screen begin of block b1 with frame title t001.


parameters: PTEST type c default 'X' as checkbox,
P_MASK type tcjed-proid,
DIALOG type c default space as checkbox,
AUTOFIT type c default 'X' as checkbox.
selection-screen end of block b1.

t001 = 'Check options'.

selection-screen begin of block b2 with frame title t002.

parameters: PDEF type c default 'X' as checkbox,


WBS type c default space as checkbox,
STD_PDEF type c default space as checkbox,
STD_WBS type c default space as checkbox,
SIM_PDEF type c default space as checkbox,
SIM_WBS type c default space as checkbox.
selection-screen end of block b2.

t002 = 'Objects to check'.

* ---------------------------------------------------------------------
start-of-selection.

if not ptest is initial.


write: / 'Running in testmode'.
else.
write: / 'Running in REAL mode.'.
endif.

if not pdef is initial.


create object gr_check type edmask_pdef.
perform check using gr_check.
endif.

if not wbs is initial.


create object gr_check type edmask_wbs.
perform check using gr_check.
endif.

if not std_pdef is initial.


create object gr_check type edmask_spdef.
perform check using gr_check.
endif.

if not std_wbs is initial.


create object gr_check type edmask_std_wbs.
perform check using gr_check.
endif.

if not sim_pdef is initial.


create object gr_check type edmask_sim_pdef.
perform check using gr_check.
endif.

if not sim_wbs is initial.


create object gr_check type edmask_sim_wbs.
perform check using gr_check.
endif.

perform show_problems.

*---------------------------------------------------------------------*
* end
*---------------------------------------------------------------------*

*---------------------------------------------------------------------*
* show all edit masks w/ problems
*---------------------------------------------------------------------*
form show_problems.
field-symbols:
<fs_tcjed> type tcjed.
data:
lv_dummy(30) type c,
wa_tcjet type tcjet.

if not gt_problem_masks is initial.


write: / 'The following edit-masks caused problems:'.

loop at gt_problem_masks assigning <fs_tcjed>.


concatenate <fs_tcjed>-proid <fs_tcjed>-posid into lv_dummy.
select single * from tcjet into wa_tcjet
where proid = <fs_tcjed>-proid and sprsl = sy-langu.

if sy-subrc ne 0.
select single * from tcjet into wa_tcjet
where proid = <fs_tcjed>-proid.
endif.

write: / lv_dummy , wa_tcjet-ktext.


endloop.
else.
write: / 'No problems found.'.
endif.
endform.

*---------------------------------------------------------------------*
* FORM check *
*---------------------------------------------------------------------*
* --> OBJ edmask_base to do the work *
*---------------------------------------------------------------------*
form check using obj type ref to edmask_base.
data:
wa_dummy type tcjed,
wa_tcjed type tcjed.
if not p_mask is initial.
call method obj->limit exporting mask = p_mask.
endif.
obj->testmode = ptest.
obj->dialogmode = dialog.
obj->squeezemode = autofit.

if not obj->lv_errorflag is initial.


call method obj->show_error.
else.
call method obj->headline.

call method obj->work.

loop at obj->lt_problem_masks into wa_tcjed.


read table gt_problem_masks into wa_dummy
with key proid = wa_tcjed-proid.

if not sy-subrc is initial.


append wa_tcjed to gt_problem_masks.
endif.
endloop.

write: / 'datasets: ' , obj->datasets.


write: / 'ok: ' , obj->okcount.
write: / 'mismatch: ' , obj->errorcount.
write: / 'dialog: ' , obj->dialogcount.
skip 1.
call method obj->show_diag.
uline.
endif.
endform.
*>>>> END OF INSERTION <<<<<<
...
*&--------------------------------------------------------------------*

You might also like