Wednesday, December 30, 2009
Replace/Remove Specified Characters From String
*** Here we check GV_STRING has any chars other than
*** legal_chars value. If anyone has we replace the value.
DATA : legal_chars TYPE string
VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789.,-*_!?'.
DATA : lv_char_value(255). " give max length
lv_char_value = gv_string.
CHECK NOT ( lv_char_value CO legal_chars ).
lv_length = strlen( gv_string ).
DO lv_length TIMES.
lv_i = sy-index - 1.
IF NOT lv_char_value+lv_i(1) CO legal_chars.
"We get the illegal char , do what you want
lv_char_value+lv_i(1) = ' '.
ENDIF.
ENDDO.
CLEAR : gv_string.
gv_string = lv_char_value.
Friday, December 18, 2009
Variant Creation At Runtime
DATA : l_variant TYPE rsvar-variant ,
l_s_vari_desc TYPE varid,
l_t_vari_contents TYPE STANDARD TABLE OF rsparams,
l_s_vari_contents TYPE rsparams,
l_t_vari_text TYPE STANDARD TABLE OF varit,
l_s_vari_text TYPE varit.
l_variant = 'NAME_OF_VARIANT'.
*** Main data
l_s_vari_desc-mandt = sy-mandt.
l_s_vari_desc-report = 'REPORT_NAME'.
l_s_vari_desc-variant = l_variant.
l_s_vari_desc-flag1 = space.
l_s_vari_desc-flag2 = space.
l_s_vari_desc-transport = 'F'.
l_s_vari_desc-environmnt = 'B'. "Variant for background
l_s_vari_desc-protected = space.
l_s_vari_desc-secu = space.
l_s_vari_desc-version = '1'.
l_s_vari_desc-ename = sy-uname.
l_s_vari_desc-edat = sy-datum.
l_s_vari_desc-etime = sy-uzeit.
l_s_vari_desc-aename = space.
l_s_vari_desc-aedat = space.
l_s_vari_desc-aetime = space.
l_s_vari_desc-mlangu = sy-langu.
*** CONTENTS
l_s_vari_contents-selname = 'S_SELOPT'.
l_s_vari_contents-kind = 'S'.
l_s_vari_contents-sign = 'I'.
l_s_vari_contents-option = 'CP'.
l_s_vari_contents-low = 'A*'.
APPEND l_s_vari_contents TO l_t_vari_contents.
l_s_vari_contents-selname = 'P_BUKRS'.
l_s_vari_contents-kind = 'P'.
l_s_vari_contents-sign = 'I'.
l_s_vari_contents-option = 'EQ'.
l_s_vari_contents-low = 'AABB'.
APPEND l_s_vari_contents TO l_t_vari_contents.
*** Description
l_s_vari_text-mandt = sy-mandt.
l_s_vari_text-langu = sy-langu.
l_s_vari_text-report = 'REPORT_NAME'.
l_s_vari_text-variant = l_variant.
l_s_vari_text-vtext = l_variant.
APPEND l_s_vari_text TO l_t_vari_text.
*** Del variant if any exists with the same name (Optional)
CALL FUNCTION 'RSAQ_DELETE_ONE_VARIANT'
EXPORTING
report = 'REPORT_NAME'
variant = l_variant
* IMPORTING
* SUBC =
EXCEPTIONS
not_authorized = 1
not_executed = 2
no_report = 3
report_not_existent = 4
report_not_supplied = 5
variant_locked = 6
OTHERS = 7
.
CALL FUNCTION 'RS_CREATE_VARIANT'
EXPORTING
curr_report = 'REPORT_NAME'
curr_variant = l_variant
vari_desc = l_s_vari_desc
TABLES
vari_contents = l_t_vari_contents
vari_text = l_t_vari_text
EXCEPTIONS
illegal_report_or_variant = 1
illegal_variantname = 2
not_authorized = 3
not_executed = 4
report_not_existent = 5
report_not_supplied = 6
variant_exists = 7
variant_locked = 8
OTHERS = 9.
Input parameters for ENQUEUE/DEQUEUE Functions . - SAP Lock Mechanism -
A closer look at the lock FM parameters which is used commonly by transactional processes.
****************************************************
X_
A further parameter X_ that defines the lock behavior when the initial value is passed exists for every lock field . If the initial value is assigned to and X_, then a generic lock is initialized with respect to . If is assigned the initial value and X_ is defined as X, the lock is set with exactly the initial value of .
Well , this means if you need a parameters initial value to lock , you must set X_ = 'X' for this purpose otherwise it locks entire values.
_SCOPE
1: Locks or lock releases are not passed to the update program. The lock is removed when the transaction is ended.
2: The lock or lock release is passed to the update program. The update program is responsible for removing the lock. The interactive program with which the lock was requested no longer has an influence on the lock behavior. This is the standard setting for the ENQUEUE function module.
3: The lock or lock release is also passed to the update program. The lock must be removed in both the interactive program and in the update program. This is the standard setting for the DEQUEUE function module.
Meaning of the
_SCOPE Values
Value
|
Description
|
_SCOPE =
1
|
The lock belongs
only to the dialog owner (owner_1), and therefore only exists in the dialog
transaction. The DEQUEUE call or the end of
the transaction, not COMMIT
WORK or ROLLBACK
WORK, cancels the lock.
|
_SCOPE =
2
|
The lock belongs
to the update owner (owner_2) only. Therefore, the update inherits the lock
when CALL FUNCTION
‘…‘ IN UPDATE TASK and COMMIT
WORK are called. The lock is released when the update transaction
is complete. You can release the lock before it is transferred to the update
using ROLLBACK WORK. COMMIT WORK has no effect, unless CALL FUNCTION ‘…‘ IN UPDATE TASK has been called.
|
_SCOPE =
3
|
The lock belongs
to both owners (owner_1 and owner_2). In other words, it combines the behavior
of both. This lock is canceled when the last of the two owners has released
it.
|
MODE_
S (read lock)
E (write lock)
X (extended write lock)
O (optimistic lock)
Locks
Modes
Type of
Lock
|
Lock
mode
|
Description
|
Shared
lock
|
S
(Shared)
|
Several users
(transactions) can access locked data at the same time in display mode.
Requests from further shared locks are accepted, even if they are from
different users. An exclusive lock set on an object that already has a shared
lock will be rejected.
|
Exclusive
lock
|
E
(Exclusive)
|
An exclusive lock
protects the locked object against all types of locks from other transactions.
Only the same lock owner can reset the lock (accumulate).
|
Exclusive but not
cumulative lock
|
X
(eXclusive non-cumulative)
|
Whereas exclusive
locks can be requested several times by the same transaction and released one
by one, an exclusive, non-cumulative lock can only be requested once by the
same transaction. Each further lock request will be rejected.
|
Optimistic
lock
|
O (Optimistic)
|
Optimistic locks
initially behave like shared locks and can be converted into exclusive locks.
See Optimistic
Locks.
|
_COLLECT
Initial Value: The lock request or lock release is sent directly to the lock server.
X: The lock request or lock release is placed in the local lock container. The lock requests and lock releases collected in this lock container can then be sent to the lock server at a later time as a group by calling the function module FLUSH_ENQUEUE.
_WAIT
Initial Value: If a lock attempt fails because there is a competing lock, the exception FOREIGN_LOCK is triggered.
X: If a lock attempt fails because there is a competing lock, the lock attempt is repeated after waiting for a certain time. The exception FOREIGN_LOCK is triggered only if a certain time limit has elapsed since the first lock attempt. The waiting time and the time limit are defined by profile parameters.
_SYNCHRON
If X is passed, the DEQUEUE function waits until the entry has been removed from the lock table. Otherwise it is deleted asynchronously, that is, if the lock table of the system is read directly after the lock is removed, the entry in the lock table may still exist.
Exceptions of the ENQUEUE Function Module
FOREIGN_LOCK: A competing lock already exists. You can find out the name of the user holding the lock by looking at system variable SY-MSGV1.
SYSTEM_FAILURE: This exception is triggered when the lock server reports that a problem occurred while setting the lock. In this case, the lock could not be set.
Ref : The SAP Lock Concept
Ref : SAP Documentation LOCK OBJECTS
Ref : The SAP Lock Concept
Ref : SAP Documentation LOCK OBJECTS
Thursday, December 17, 2009
Scheduling Background Job At Runtime - ABAP
data : gv_job_name type btcjob ,
gv_jobcount type btcjobcnt,
gv_variant type rsvar-variant.
constants : gc_bg_repid type sy-repid value 'ZZZZ_PROGRAM_NAME'.
data : gv_step like tbtcjob-stepcount.
*** Simply we initiate the operation
gv_job_name = 'NAMEOFJOB'.
call function 'JOB_OPEN'
exporting
jobname = gv_job_name
importing
jobcount = gv_jobcount
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4.
*** Submit the report and needed variant name
gv_variant = 'VARIANT111'.
call function 'JOB_SUBMIT'
exporting
authcknam = sy-uname
jobcount = gv_jobcount
jobname = gv_job_name
report = gc_bg_repid
variant = gv_variant
importing
step_number = gv_step
exceptions
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
others = 10.
*** here gv_step equals to 1 as a first step
*** You can multiple steps by using the job_submit function
*** Use Another variant or report for the second step
gv_variant = 'VARIANT222'.
call function 'JOB_SUBMIT'
exporting
authcknam = sy-uname
jobcount = gv_jobcount
jobname = gv_job_name
report = gc_bg_repid
variant = gv_variant
importing
step_number = gv_step
exceptions
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
others = 10.
*** here gv_step equals to 2 as a second step
*** Finally release the job.
*** According to your scheduling options lots of input
*** parameters exist inside the function
*** You've got your job number
call function 'JOB_CLOSE'
exporting
jobcount = gv_jobcount
jobname = gv_job_name
strtimmed = 'X'
* IMPORTING
* JOB_WAS_RELEASED =
* CHANGING
* RET =
exceptions
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
invalid_target = 8
others = 9.
gv_jobcount type btcjobcnt,
gv_variant type rsvar-variant.
constants : gc_bg_repid type sy-repid value 'ZZZZ_PROGRAM_NAME'.
data : gv_step like tbtcjob-stepcount.
*** Simply we initiate the operation
gv_job_name = 'NAMEOFJOB'.
call function 'JOB_OPEN'
exporting
jobname = gv_job_name
importing
jobcount = gv_jobcount
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4.
*** Submit the report and needed variant name
gv_variant = 'VARIANT111'.
call function 'JOB_SUBMIT'
exporting
authcknam = sy-uname
jobcount = gv_jobcount
jobname = gv_job_name
report = gc_bg_repid
variant = gv_variant
importing
step_number = gv_step
exceptions
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
others = 10.
*** here gv_step equals to 1 as a first step
*** You can multiple steps by using the job_submit function
*** Use Another variant or report for the second step
gv_variant = 'VARIANT222'.
call function 'JOB_SUBMIT'
exporting
authcknam = sy-uname
jobcount = gv_jobcount
jobname = gv_job_name
report = gc_bg_repid
variant = gv_variant
importing
step_number = gv_step
exceptions
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
others = 10.
*** here gv_step equals to 2 as a second step
*** Finally release the job.
*** According to your scheduling options lots of input
*** parameters exist inside the function
*** You've got your job number
call function 'JOB_CLOSE'
exporting
jobcount = gv_jobcount
jobname = gv_job_name
strtimmed = 'X'
* IMPORTING
* JOB_WAS_RELEASED =
* CHANGING
* RET =
exceptions
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
invalid_target = 8
others = 9.
Sunday, December 13, 2009
Flex Builder Configuration - Changing Locale Setting
Add the following lines inside the FlexBuilder.ini file.
---------------------------
-Duser.language=en
-Duser.location=us
---------------------------
---------------------------
-Duser.language=en
-Duser.location=us
---------------------------
Subscribe to:
Posts (Atom)