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.