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
---------------------------
Tuesday, November 24, 2009
Set Listbox Values At Selection Screen
When you hit F8 , the p_par will have the key fields value of selected list item.
*** Type Pool
type-pools : vrm.
.
.
*** Her's the definition of listbox parameter
parameters : p_par type mara-mtart as listbox visible length 15.
.
.
*** Event Block
at selection-screen output.
perform at_sel_output.
.
.
.
*&---------------------------------------------------------------------*
*& Form at_sel_output
*&---------------------------------------------------------------------*
form at_sel_output.
data : lt_list type vrm_values with header line .
lt_list-key = 'K1'.
lt_list-text = ' First One'.
append lt_list.
lt_list-key = 'K2'.
lt_list-text = ' Second One'.
append lt_list.
lt_list-key = 'K3'.
lt_list-text = ' Third One'.
append lt_list.
call function 'VRM_SET_VALUES'
exporting
id = 'P_PAR'
values = lt_list[]
exceptions
id_illegal_name = 1
others = 2.
endform. "at_sel_output
Thursday, November 19, 2009
Get print parameters and submit report to sap spool
DATA: p_parameters TYPE pri_params,
a_parameters TYPE arc_params,
valid(1).
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
archive_mode = '1' " Just print
IMPORTING
out_parameters = p_parameters
out_archive_parameters = a_parameters
valid = valid
EXCEPTIONS
invalid_print_params = 2
OTHERS = 4.
CHECK valid EQ 'X'.
SUBMIT zz_your_report_name WITH p_submit EQ 'X'
TO SAP-SPOOL
SPOOL PARAMETERS p_parameters
ARCHIVE PARAMETERS a_parameters
WITHOUT SPOOL DYNPRO.
Sunday, November 15, 2009
Smartforms related standart demo programs
SF_BATCH_GENERATE Program for Generating SMART FORMS in Batch
SF_EXAMPLE_01 Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_01_BACKUP Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_02 Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_02_BACKUP Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_03 Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_03_BACKUP Sample Program for Form Printing Using Smart Forms
SF_TOTALS Examples for Totalling Different Currencies
SF_XSF_DEMO Smart Forms: XSF Output - Demo Program
SF_XSF_DEMO_MAIL Send Form and Graphics by E-Mail
SF_XSF_DEMO2
SF_XSF_DEMO3
SF_EXAMPLE_01 Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_01_BACKUP Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_02 Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_02_BACKUP Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_03 Sample Program for Form Printing Using Smart Forms
SF_EXAMPLE_03_BACKUP Sample Program for Form Printing Using Smart Forms
SF_TOTALS Examples for Totalling Different Currencies
SF_XSF_DEMO Smart Forms: XSF Output - Demo Program
SF_XSF_DEMO_MAIL Send Form and Graphics by E-Mail
SF_XSF_DEMO2
SF_XSF_DEMO3
Wednesday, November 11, 2009
Display / Delete Application log (Bal Log)
*** Delete Given log
*** Display Given logs
call function 'BAL_DB_DELETE'
exporting
i_t_lognumber = lognumber
i_in_update_task = space
i_with_commit_work = space
exceptions
no_logs_specified = 1
others = 2.
*** Display Given logs
data: begin of lt_log occurs 10,
lognumber like balhdr-lognumber,
end of lt_log.
refresh lt_log.
lt_log-lognumber = lognumber . " log
append lt_log.
call function 'APPL_LOG_DISPLAY_WITH_LOGNO'
tables
lognumbers = lt_log
exceptions
no_authority = 1
others = 2.
if sy-subrc NE 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Tuesday, November 3, 2009
IDOC Data Display and Delete
There are two usefull functions for display and delete IDOC data.
First function which displays a single idoc data is no different than we02 transaction. It displays idoc data using a tree structure.
The ohter function which deletes given idoc data helps you to remove idoc related data from edidc , edids and
edi40 (OR edi30c OR edidoc , for older versions) . However you can do it using we11 transaction. Using the standart reports is always recomended. There may be much more idoc related data to remove like application log. Here i just give you an opinion about the function modules behaviour.
First function which displays a single idoc data is no different than we02 transaction. It displays idoc data using a tree structure.
call function 'EDI_DOCUMENT_DATA_DISPLAY'
exporting
docnum = gv_docnum
exceptions
no_data_record_found = 1
others = 2.
if sy-subrc NE 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
The ohter function which deletes given idoc data helps you to remove idoc related data from edidc , edids and
edi40 (OR edi30c OR edidoc , for older versions) . However you can do it using we11 transaction. Using the standart reports is always recomended. There may be much more idoc related data to remove like application log. Here i just give you an opinion about the function modules behaviour.
call function 'EDI_DOCUMENT_DELETE'
exporting
document_number = gv_docnum
exceptions
idoc_does_not_exist = 1
document_foreign_lock = 2
idoc_cannot_be_deleted = 3
not_all_tables_deleted = 4
others = 5.
if not sy-subrc is initial.
message id sy-msgid type 'I' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Wednesday, October 28, 2009
Call Default Table/View Maintenance Screen (SM30)
The example below shows calling maintenance screen (SM30) using a function module. Especially if you'd like to fix a value like company code , simply add values to dba_sellist and that's it. Maintenance just works for the fixed values. First col. value is fixed at the screenshot.
data : rangetab type table of vimsellist with header line.
rangetab-viewfield = 'BUKRS'.
rangetab-operator = 'EQ'.
rangetab-value = p_value.
rangetab-tabix = 2.
rangetab-converted = 'X'.
append rangetab.
call function 'VIEW_MAINTENANCE_CALL'
exporting
action = 'U' " Update 'S' Show
view_name = 'TABLE_OR_VIEW_NAME'
check_ddic_mainflag = 'X'
tables
dba_sellist = rangetab[]
exceptions
client_reference = 1
foreign_lock = 2
invalid_action = 3
no_clientindependent_auth = 4
no_database_function = 5
no_editor_function = 6
no_show_auth = 7
no_tvdir_entry = 8
no_upd_auth = 9
only_show_allowed = 10
system_failure = 11
unknown_field_in_dba_sellist = 12
view_not_found = 13
maintenance_prohibited = 14
others = 15.
if sy-subrc NE 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Transaction Codes For SAP Data Archiving
- DB15
- AOBJ
- TAANA
- SARA
- SARI
- FILE
- SF01
- SAR_SHOW_MONITOR
- ARCH_PROT
- OAC0
- ACLA
- AFX_WB
- ARCHGUIDE
- AS_AFB
Link for SAP online doc :
Friday, September 4, 2009
Convert Float To Packed Number
We can use the round function to convert any FLTP value to packed number. Technically it is a rounding operation also. After having the rounded value in packed format , you can easily arrange your display format etc.
DATA : fl TYPE float.
DATA : pc TYPE p LENGTH 16 DECIMALS 2.
*** Just to try
fl = '-199.22' .
CALL FUNCTION 'ROUND'
EXPORTING
decimals = 2
input = fl
sign = 'x'
IMPORTING
output = pc
EXCEPTIONS
input_invalid = 1
overflow = 2
type_invalid = 3
OTHERS = 4.
IF sy-subrc > 0.
*** Sth Wrong
ELSE.
*** Now you’ve got your rounded value ”pc”
ENDIF.
Split Large Char Field Into Table
To Split a large char field into table , you can use the function below. You may say , there are lots of alternative keywords and functions for this approach. Here’s the difference of this function ; It separates given character field considering the white spaces and fills the given tables 1st component which must be char type and has any given length. Table can have only one component.
This function is very usefull when you need to split a given free text into fixed lentgh parts (sap script texts ) .
——————————————————————————–
Text Field Type CDATA : free_text(10000).
*** Table to fill Splitted lines
DATA : BEGIN OF lt_table OCCURS 1,
filed(10) ,
other_field TYPE i ,
n_filed TYPE n ,
p_field TYPE p ,
END OF lt_table .
*** Dummy Text
free_text = ’123 123 12345678 12345678567890Z 1234567 3243324′.*** Function To Split large Char. Field Into Table
CALL FUNCTION ’OCS_SPLIT_TEXTLINE‘
EXPORTING
iv_textline = free_text
* iv_preserve_space = ’X' if you like to preserve spaces
TABLES
et_fragments = lt_table[]
EXCEPTIONS
wrong_fragment_type = 1
OTHERS = 2.
IF sy-subrc <> 0.EXPORTING
iv_textline = free_text
* iv_preserve_space = ’X' if you like to preserve spaces
TABLES
et_fragments = lt_table[]
EXCEPTIONS
wrong_fragment_type = 1
OTHERS = 2.
” Sth wrong
ENDIF.
Cloud computing Nedir ?
Cloud computing , son zamanlarda sıkça rastlanan ve üzerinde durulan bir konu olarak karşımıza çıkıyor. Terim olarak yabancı olsak da , bu mimari tabanlı servisleri donanım/yazılım anlamında birçoğumuz kullanmaktayız. Özellikle de Web 2.0 teknolojileri geliştikçe , bu anlamda yapılabilecekler sınırsız sayıda olmaya başladı. Web üzerinde ofis ve pdf dökümanlarına takla attırmaktan , proje diyagramları çizmeye , slaytlar hazırlayabilmekten , ayrıntılı resim işlemeye kadar her türlü olanak bize bu mimari kapsamında ve web 2.0 teknolojilerinin nimetleri sayesinde sunulmuş durumda. Bu örneklerin dışında , çok ünlü olan kurumsal yazılımlar (özellikle HR,CRM,SLA konulu) da mevcut salesforce.com gibi.
Netice olarak bu kavram , çok hızlı değişen/gelişen teknolojiye ve sayısı artan platformlara/yazılımlara istinaden ortaya çıkan donanım ve yazılım upgrade etme ihtiyaçlarını ortadan kaldıran çözüm olarak düşünülebilir. Zira kullanıcı , yenilikler için yazılım ve donanımdan endişe etmek durumunda kalmadan ilgili mimari çerçevesinde sorunsuz bir kullanım gerçekleştirecektir. Aşağıdaki videoda da gençler konudan ne anladıklarını aktarıyorlar.
Submit program using variant and changing variant at runtime
You need to submit a program in background using a variant which is fetched from specified customizing table. However there is a selection field that needed to be ignored or changed. For example , variant includes company code specification and the other selections. I have to use the variant selections without company code specification.
In this case , just before submitting the program , we can change the variant data . After gathering data we change back the variant. By the help of functions below , we kept the variant unchanged .
In this case , just before submitting the program , we can change the variant data . After gathering data we change back the variant. By the help of functions below , we kept the variant unchanged .
DATA : program TYPE rsvar-report ,
variant TYPE rsvar-variant.
DATA : lv_rc TYPE i.
DATA : variant_backup TYPE TABLE OF rsparams .
DATA : lt_values TYPE TABLE OF rsparams ,
ls_values LIKE LINE OF lt_values,
lt_objects TYPE TABLE OF vanz .
DATA : ls_varid TYPE varid.
DATA : lt_backup TYPE TABLE OF rsparams .
program = ‘ZZZ_PROG’.
variant = ‘ZZZ_VARI’.
CALL FUNCTION ‘RS_VARIANT_CONTENTS’
EXPORTING
report = program
variant = variant
TABLES
valutab = lt_values[]
OBJECTS = lt_objects[]
EXCEPTIONS
variant_non_existent = 1
variant_obsolete = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE ‘I’ NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR : lt_backup[] , variant_backup[].
LOOP AT lt_values INTO ls_values
WHERE selname = ‘YOUR_SELECTION_FIELD’.
*** HERE YOU CAN ADD/MODIFY/DELETE SELECTION DATA
ls_values-low = ‘1234′.
APPEND ls_values TO lt_backup.
ENDLOOP.
*** BACKUP
variant_backup[] = lt_backup[].
CALL FUNCTION ‘RS_CHANGE_CREATED_VARIANT’
EXPORTING
curr_report = program
curr_variant = variant
vari_desc = ls_varid
only_contents = ‘X’
TABLES
vari_contents = lt_values[]
* VARI_TEXT =
* VARI_SEL_DESC =
OBJECTS = lt_objects[]
EXCEPTIONS
illegal_report_or_variant = 1
illegal_variantname = 2
not_authorized = 3
not_executed = 4
report_not_existent = 5
report_not_supplied = 6
variant_doesnt_exist = 7
variant_locked = 8
selections_no_match = 9
OTHERS = 10
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE ‘I’ NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR : exists.
CALL FUNCTION ‘RS_VARIANT_EXISTS’
EXPORTING
report = program
variant = variant
IMPORTING
r_c = lv_rc
EXCEPTIONS
not_authorized = 1
no_report = 2
report_not_existent = 3
report_not_supplied = 4
OTHERS = 5.
IF sy-subrc EQ 0 AND lv_rc EQ 0.
SUBMIT zzz_prog
USING SELECTION-SET variant
WITH p_submit = ‘X’ AND RETURN.
CLEAR : gt_tab.
IMPORT gt_tab TO gt_tab FROM MEMORY ID ‘ZZZ_ID’.
ENDIF.
CALL FUNCTION ‘RS_CHANGE_CREATED_VARIANT’
EXPORTING
curr_report = program
curr_variant = variant
vari_desc = ls_varid
only_contents = ‘X’
TABLES
vari_contents = variant_backup[]
* VARI_TEXT =
* VARI_SEL_DESC =
OBJECTS = lt_objects[]
EXCEPTIONS
illegal_report_or_variant = 1
illegal_variantname = 2
not_authorized = 3
not_executed = 4
report_not_existent = 5
report_not_supplied = 6
variant_doesnt_exist = 7
variant_locked = 8
selections_no_match = 9
OTHERS = 10
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE ‘I’ NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Tuesday, August 25, 2009
How to find a transaction code which calls SM30 for a specific table maintenance
We can simply create table maintenance program using table maintenance generator tool for a specific Z table that we have . And it's the fastest way to let the user start maintaining related data. After that usually people create a transaction code for this auto-generated program to make it easily accessible from end users.
You have a Ztable and you don't know if someone created a transaction code for the maintenance program. Go to SE16->TSTCP . There are 2 fields. First one is transaction code , type Z* and the other one is PARAM which represents the transaction code and its parameters info to call. Type *Ztable* .
Usefull FM's for this purpose :
PRGN_GET_ORIGINAL_TRANSACTION
RS_TRANSACTION_SINGLE_GET
RS_PARAMETER_TRANSACTION_GET
SRT_CONVERT_PARAM_TO_SREPOVARI
Wednesday, August 19, 2009
ABAP Confirmation Popup Screen
Before a critical operation starts , we often need user to confirm the operation just to be sure that the process wasn't started mistakenly. Simplest example for this purpose ;
data : lv_mes type string.data lv_answer.lv_mes = 'Your question here'.call function 'POPUP_TO_CONFIRM'exportingtitlebar = 'Popup Title'text_question = lv_mestext_button_1 = 'YES'icon_button_1 = 'ICON_OKAY' " 1st Buttons icontext_button_2 = 'NO'icon_button_2 = 'ICON_CANCEL' "2nd Buttons icondefault_button = '2' " Default choice - NOdisplay_cancel_button = 'X' " 3rd button(CANCEL) is visible or notimportinganswer = lv_answerexceptionstext_not_found = 1others = 2.**** RESULTIF lv_answer = '1'. " 1st button has clickedELSEIF lv_answer = '2'. " 2nd button has clickedELSEIFlv_answer = 'A'. " CANCEL button has clickedENDIF.
Tuesday, August 18, 2009
Graphical Screen Painter Problems
If you have trouble with your screen painter , there might be several reasons. Before applying the wide range solution which is reinstalling sapgui , you can take a look at the statements below .
- SE38 -> Utilities -> Graphical editor (CHECK)
- Check your "gnetx.exe" and "eumfcdll.dll" files exists in your installation folder,
- check your related port 33
XX(means if your system number 01 -> port -> 3301 ) is open. - Check your EU_SCRP_WN32 RFC destination.
Subscribe to:
Posts (Atom)