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 C
DATA : 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.
” 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 .
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'
exporting
titlebar = 'Popup Title'
text_question = lv_mes
text_button_1 = 'YES'
icon_button_1 = 'ICON_OKAY' " 1st Buttons icon
text_button_2 = 'NO'
icon_button_2 = 'ICON_CANCEL' "2nd Buttons icon
default_button = '2' " Default choice - NO
display_cancel_button = 'X' " 3rd button(CANCEL) is visible or not
importing
answer = lv_answer
exceptions
text_not_found = 1
others = 2.
**** RESULT
IF lv_answer = '1'. " 1st button has clicked
ELSEIF lv_answer = '2'. " 2nd button has clicked
ELSEIFlv_answer = 'A'. " CANCEL button has clicked
ENDIF.

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 .






  1. SE38 -> Utilities -> Graphical editor (CHECK)
  2. Check your "gnetx.exe" and "eumfcdll.dll" files exists in your installation folder,
  3. check your related port 33XX(means if your system number 01 -> port -> 3301 ) is open.
  4. Check your EU_SCRP_WN32 RFC destination.