ABAP

ABAP

Tuesday, January 15, 2013

Ranges , Join , Split , List Box

Ranges 


****  populate range table to receive entries within a range
wa_ebeln-sign   = 'I'.   "I = include, E = exclude
wa_ebeln-option = 'BT'.  "EQ, BT, NE ....
wa_ebeln-low    = '11111111'.
wa_ebeln-high   = '99999999'.

append wa_ebeln to r_ebeln.

select ebeln ebelp statu aedat matnr menge meins netpr peinh
  from ekpo
  into table it_ekko
 where ebeln in r_ebeln.





  RANGES: r_ustyp FOR usr02-ustyp.
  LOOP AT gt_list.
    r_ustyp-option = 'EQ'.
    r_ustyp-sign   = 'I' .
    r_ustyp-low    = gt_list-key.
    APPEND r_ustyp.
  ENDLOOP.


JOIN


    select vbak~vbeln  vbak~erdat vbak~auart
           vbak~vkorg  vbak~kunnr vbak~vdatu
           vbap~posnr
           vbap~matnr  vbap~werks vbap~vstel
           vbap~kwmeng vbap~vrkme vbap~netwr
           vbap~meins  vbap~prodh vbap~abgru vbap~zzilreqdeldate
           vbap~zzreason vbap~zzreason1 vbap~zzilordqty
           vbap~zzinuom  vbap~zzlastcustqty vbap~zzlastsaveqty
           vbap~zzlastunit vbap~zzlastrdd vbap~zzilweekdat
           vbap~zzlcrdd vbap~zzlcuom vbap~pstyv
      into corresponding fields of table lt_vbeln
      from vbak as vbak inner join vbap as vbap
      on vbak~vbeln = vbap~vbeln
      where vbak~vbeln in s1_vbeln
        and vbap~pstyv ne 'TAPA'.


SPLIT

Asağıdaki kodda sunu sağlıyoruz diyelimki elimizde 

2000/2001/2002/2003/2000/2001 diye bir string olsun . 

Bunları tek tek olacak sekılde '/' 'dan bolerek gt_split tablosuna atıyoruz . 
Daha sonra burdan aynı kayıtları siliyoruz ve tekrar  birlestiriyoruz . Bu komutla elimizdeki string degiskeni belli bir ayrıracla birbirlerine baglılarsa ıstedıgımız gibi ayırmıs oluyoruz . 


  DATA:  BEGIN OF gt_split OCCURS 0,
         split(50) TYPE c,
         END OF gt_split.



*----->>> Added by SOZYURT CR9519 14.01.2013 10:57:20
      SPLIT it_mara-variants AT '/' INTO TABLE gt_split .
      SORT gt_split.
      DELETE ADJACENT DUPLICATES FROM gt_split.
      CLEAR : l_variant.
      LOOP AT gt_split.
        CONCATENATE l_variant '/' gt_split-split INTO l_variant.
      ENDLOOP.
      MOVE l_variant TO it_mara-variants.
*-----<<< Added by SOZYURT


like 9% 


LIST BOX

parameters:     p_select type char10 as listbox visible length 20
                         modif id alv default 'A'.



at selection-screen output.
perform f_fill_list.


*&---------------------------------------------------------------------*
*&      Form  f_fill_list
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form f_fill_list.
  clear: gt_list, gt_list[].
  gs_stab-key  = 'A'.
  gs_stab-text = text-015."Dialog
  append gs_stab to gt_list.
  gs_stab-key  = 'B'.
  gs_stab-text = text-016."System
  append gs_stab to gt_list.
  gs_stab-key  = 'C'.
  gs_stab-text = text-017."Com Data
  append gs_stab to gt_list.
  gs_stab-key  = 'L'.
  gs_stab-text = text-018."Ref
  append gs_stab to gt_list.
  gs_stab-key  = 'S'.
  gs_stab-text = text-019."Service
  append gs_stab to gt_list.

  call function 'VRM_SET_VALUES'
    exporting
      id     = 'P_SELECT'
      values = gt_list.

endform.                    "f_fill_list



Friday, January 4, 2013

sapscript programa dallanarak deger alma,standart text smartforma deger atama,sapscript font


***Standart text'e programdan,smartformdan değer atama

Ornek olarak bir standart textiniz var diyelim bunu smartformda basıyorsunuz ve bu text'in son satırı ise soyle son satırda diyelim ki yetkili kisi veya basan userın adı tarzı bir değişken kısım var bunun icin yapmamız gereken soyle



Burda gv_authorized diye bir değişkenimiz var buda programdan smartforma gonderdıgımız bir değişken .




Alttaki sekılde standart text olarak eklememizle cıktımızda artık yer almaktadır .




***Sapscriptten programa dallanarak sapscripte dondurme 

sapscripttin ici :

Degisken tanımlanır kullanılcak deger programa gonderılıp bu degıskene hesaplanarak cekılır

DEFINE &LV_STCEG& = '' .
PERFORM FIND_STCEG IN PROGRAM YILFI_GLI001
USING &ZIS_FORM-KONTO&
CHANGING &LV_STCEG&
ENDPERFORM.

Program tarafında onemli olan sey form adından sonra
 TABLES in_par STRUCTURE itcsy out_par STRUCTURE itcsy.

in_par degeri ve outpar degeridir bunları giren ve cıkan olarak dusunebılırız istedigimiz her islemi yapıp scripte donduruyor olabılırız .

PROGRAM  yilfi_gli001.
*&---------------------------------------------------------------------*
*&      Form  calculate_betrag
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_ZINSZAHL text
*      -->P_BETRAG   text
*----------------------------------------------------------------------*
FORM calculate_betrag TABLES in_par STRUCTURE itcsy out_par STRUCTURE itcsy.

  DATA lv_betrag TYPE BTRGAB.
  READ TABLE in_par INDEX 1"""WITH KEY name = 'ZINSSATZTAB-BETRAG'.
  TRANSLATE in_par-value USING '. , '.
  CONDENSE in_par-value NO-GAPS.
  lv_betrag = in_par-value .
  lv_betrag = lv_betrag / 100.

  READ TABLE out_par INDEX 1.
  WRITE lv_betrag TO out_par-value CURRENCY 'USD'.

  CONDENSE out_par-value.

  MODIFY out_par INDEX 1.
ENDFORM.                    "calculate_betrag

FORM convert_btrgab TABLES in_par STRUCTURE itcsy out_par STRUCTURE itcsy.

  DATA lv_betrag TYPE BTRGAB.
  READ TABLE in_par INDEX 1"""WITH KEY name = 'ZINSSATZTAB-BETRAG'.
  TRANSLATE in_par-value USING '. , '.
  CONDENSE in_par-value NO-GAPS.
  lv_betrag = in_par-value .
  lv_betrag = lv_betrag / 100.

  READ TABLE out_par INDEX 1.
  WRITE lv_betrag TO out_par-value CURRENCY 'USD'.

  CONDENSE out_par-value.

  MODIFY out_par INDEX 1.
ENDFORM.                    "calculate_betrag
*&---------------------------------------------------------------------*
*&      Form  find_stceg
*&---------------------------------------------------------------------*
FORM find_stceg TABLES in_par STRUCTURE itcsy out_par STRUCTURE itcsy.
  READ TABLE in_par INDEX 1.

  DATA lv_kunnr TYPE kunnr .
  lv_kunnr = in_par-value.

  DATA lv_stceg TYPE kna1-stceg.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      input  = lv_kunnr
    IMPORTING
      output = lv_kunnr.


  SELECT SINGLE stceg
    INTO lv_stceg
    FROM kna1
   WHERE kunnr = lv_kunnr.

  READ TABLE out_par INDEX 1.

  out_par-value = lv_stceg.

  MODIFY out_par INDEX 1.

ENDFORM.                    "find_stceg

***Sap Script Fonts 
c0 7 x 9 Standard (86XX font)
c1 7 x 11 OCR (86XX font)
c2 10 x 14 Standard (86XX font)
c3-c6 User-defined fonts
c7 5 x 7 Standard (86XX font)
c8-c19 User-defined fonts
c20 8 point
c21 12 point
c22 20 point
c23 OCR A
c24 OCR B size 2
c25 Swiss Mono 721 standard outline font
c26 Swiss Mono 721 bold outline font
c28 Dutch Roman 801 proportional outline font
c30 6 point monospace bold
c31 8 point monospace bold
c32 10 point monospace standard
c33 10 point monospace bold
c34 12 point monospace bold
c35 16 point monospace standard
c36 16 point monospace bold
c37 20 point monospace bold
c38 24 point monospace standard
c39 24 point monospace bold
c40 30 point monospace bold
c41 36 point monospace bold

Thursday, January 3, 2013

XML upload download

*-------------- DATA
data : t001 like table of yautmm0004 with header line.
data : begin of itab occurs 0,
a(100type c,
end of itab.

data: xml_out type string .

data : begin of upl occurs 0,
f(255type c,
end of upl.
data: xmlupl type string .

******************************* FIRST PHASE
******************************* FIRST PHASE
******************************* FIRST PHASE

*------------------ Fetch Data

select * from tabloadı into table t001 up to 2 rows.

*------------------- XML
call transformation ('ID')
source tab = t001[]
result xml xml_out.

*------------- Convert to TABLE

call function 'HR_EFI_CONVERT_STRING_TO_TABLE'
exporting
i_string = xml_out
i_tabline_length = 100
tables
et_table = itab.
*-------------- Download

call function 'GUI_DOWNLOAD'
exporting
filetype = 'BIN'
filename = 'c:\dene.xml'
tables
data_tab = itab.

******************************* SECOND PHASE
******************************* SECOND PHASE
******************************* SECOND PHASE
*BREAK-POINT.
*REFRESH t001.
*CLEAR t001.

call function 'GUI_UPLOAD'
exporting
filename = 'C:\dene.XML'
filetype = 'BIN'
tables
data_tab = upl.

loop at upl.
concatenate xmlupl upl-f into xmlupl.
endloop.

*------------------- XML
call transformation ('ID')
source xml xmlupl
result tab = t001[]
.
break-point.

Authorizations & Roles & Message Class Generator(Mesaj Class Yaratma Programı Batch)


suim  --->> user information system
 pfcg --- >> role maintenance

su21 --- >> maintain authorization objects
se54 --- >> auth group cr.



constants :
       gc_app(1)   type c value  'Y',
       gc_mc(25type c value  'Message Class For'.


data : gt_bdcdata like bdcdata    occurs 0 with header line,
       gt_messtab like bdcmsgcoll occurs 0 with header line,
       gt_data1   type table of yutbc0002 with header line,
       gt_cname   type table of yutbc0001 with header line,
       gv_record  type string,
       gv_color,
       lt_t100a   type table of t100a with header line,
       lv_name    type string,
       ls_opt     like  ctu_params.


 data : begin of gt_messall occurs 0,
        message(255),
        end of gt_messall.

*--SELECTION-SCREEN
selection-screen : begin of block b1 with frame title text-001.
parameters : p_cntry like yutbc0001-cntry obligatory matchcode object
             yubczz01,
             p_reqno like ko008-trkorr,
             p_mode  like ctu_params-dismode obligatory default 'A'.

selection-screen : end of block b1.


start-of-selection.

  perform selection.

  loop at gt_data1.

    concatenate gc_app p_cntry gt_data1-spmdl into gv_record.
    perform cname.
    perform check.

  endloop.
*====================================================================*
*  Form : selection                                                *
*====================================================================*
form selection.

  select spmdl from yutbc0002
               into corresponding fields of table gt_data1.

  select * from yutbc0001
           into corresponding fields of table gt_cname.

endform.                    "selection
*====================================================================*
*  Form : cname                                                     *
*====================================================================*
form cname.

  clear lv_name.
  read table gt_cname
  with key cntry = p_cntry.
  if sy-subrc eq 0.
    if p_cntry eq gt_cname-cntry.
      concatenate gc_mc gt_data1-spmdl gt_cname-descr
      into lv_name
       separated by space.
    endif.
  endif.

endform.                    "cname
*====================================================================*
*  Form : fiil                                                        *
*====================================================================*
form fill.

    perform fill_bdcdata using 'SAPLWBMESSAGES' '0100' 'X' '' ''.
    perform fill_bdcdata using '' '' '' 'BDC_CURSOR' 'RSDAG-ARBGB'.
    perform fill_bdcdata using '' '' '' 'RSDAG-ARBGB' gv_record.
    perform fill_bdcdata using '' '' '' 'BDC_OKCODE' '=WB_CREATE'.
    perform fill_bdcdata using '' '' '' 'RSDAG-MSGFLAG' 'X'.


    perform fill_bdcdata using 'SAPLWBMESSAGES' '1000' 'X' '' ''.
    perform fill_bdcdata using '' '' '' 'BDC_OKCODE' '=MESS'.
    perform fill_bdcdata using '' '' '' 'BDC_SUBSCR'
           'SAPLWBMESSAGES                          0102SUB'.
    perform fill_bdcdata using '' '' '' 'BDC_CURSOR' 'T100A-STEXT'.
    perform fill_bdcdata using '' '' '' 'T100A-RESPUSER' 'SOZYURT'.
    perform fill_bdcdata using '' '' '' 'T100A-STEXT' lv_name.


    perform fill_bdcdata using 'SAPLSTRD' '0100' 'X' '' ''.
    perform fill_bdcdata using '' '' '' 'BDC_CURSOR' 'KO007-L_DEVCLASS'.
    perform fill_bdcdata using '' '' '' 'BDC_OKCODE' '=ADD'.
    perform fill_bdcdata using '' '' '' 'KO007-L_DEVCLASS' gv_record.
    perform fill_bdcdata using '' '' '' 'KO007-L_AUTHOR' sy-uname.


    perform fill_bdcdata using 'SAPLSTRD' '0300' 'X' '' ''.
    perform fill_bdcdata using '' '' '' 'BDC_CURSOR' 'KO008-TRKORR'.
    perform fill_bdcdata using '' '' '' 'BDC_OKCODE' '=LOCK'.
    perform fill_bdcdata using '' '' '' 'KO008-TRKORR' p_reqno.


    perform fill_bdcdata using 'SAPLWBMESSAGES' '1000' 'X' '' ''.
    perform fill_bdcdata using '' '' '' 'BDC_OKCODE' '=WB_SAVE'.
    perform fill_bdcdata using '' '' '' 'BDC_SUBSCR'
          'SAPLWBMESSAGES                          0101SUB'.
    perform fill_bdcdata using '' '' '' 'NUMMER' '000'.
    perform fill_bdcdata using '' '' '' 'T100-TEXT(01)' '& & & &'.


    perform fill_bdcdata using 'SAPLWBMESSAGES' '1000' 'X' '' ''.
    perform fill_bdcdata using '' '' '' 'BDC_OKCODE' '=WB_BACK'.
    perform fill_bdcdata using '' '' '' 'BDC_SUBSCR'
          'SAPLWBMESSAGES                          0101SUB'.
    perform fill_bdcdata using '' '' '' 'BDC_CURSOR' 'NUMMER'.
    perform fill_bdcdata using '' '' '' 'NUMMER' '000'.


    perform fill_bdcdata using 'SAPLWBMESSAGES' '0100' 'X' '' ''.
    perform fill_bdcdata using '' '' '' 'BDC_CURSOR' 'RSDAG-ARBGB'.
    perform fill_bdcdata using '' '' '' 'BDC_OKCODE' '=WB_BACK'.
    perform fill_bdcdata using '' '' '' 'RSDAG-ARBGB' ''.
    perform fill_bdcdata using '' '' '' 'RSDAG-MSGFLAG' 'X'.


endform.                    "fill
*====================================================================*
*  Form : fill_bdcdata                                                *
*====================================================================*
form fill_bdcdata  using  p1 p2 p3 p4 p5.
     gt_bdcdata-program  = p1.
     gt_bdcdata-dynpro   = p2.
     gt_bdcdata-dynbegin = p3.
     gt_bdcdata-fnam     = p4.
     gt_bdcdata-fval     = p5.

  append gt_bdcdata.
endform.                    "fill_bdcdata
*====================================================================*
*  Form : call_transaction_se91                                       *
*====================================================================*
form call_transaction_se91 using prf_record.

  ls_opt-dismode =  p_mode.

  call transaction 'SE91' using gt_bdcdata options from ls_opt
  messages into gt_messtab.

  clear : gt_bdcdata,gt_bdcdata[].


  loop at gt_messtab.

    message id gt_messtab-msgid type gt_messtab-msgtyp
    number gt_messtab-msgnr
    with gt_messtab-msgv1 gt_messtab-msgv2 gt_messtab-msgv3
    gt_messtab-msgv4
    into gt_messall-message.



    at first.
      write : / 'For Message Class' color = 1, gv_record color = 1.
      uline.
      uline.
    endat.
      write : gt_messall-message.

  endloop.
    clear gt_messtab[].
  uline.
endform.                         "call_transaction_se91
*====================================================================*
*  Form : check                                                       *
*====================================================================*
form check.
  select * from t100a into corresponding fields of table lt_t100a.
  read table lt_t100a with key arbgb = gv_record.

  if lt_t100a-arbgb eq gv_record.


    write : / 'For Message Class' color = 1 , gv_record color = 1.
    write : / 'Message Class Exist' color = 6.
    uline.
  else.
    perform fill.
    perform call_transaction_se91 using gv_record.
  endif.

endform.                    "check

selection screen F1 help, message tipleri



http://saptechnical.com/Tutorials/ABAP/F1Help/Create.htm



SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 1.
PARAMETERS: cb_check AS CHECKBOX .
SELECTION-SCREEN COMMENT 4(60) text-003 FOR FIELD cb_check.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.



AT SELECTION-SCREEN ON HELP-REQUEST FOR cb_check.
  CALL FUNCTION 'DSYS_SHOW_FOR_F1HELP'
    EXPORTING
      dokclass         = 'TX'
      doklangu         = sy-langu
      dokname          = 'Y_F1_HELP_FOR_CHECK'
    EXCEPTIONS
      class_unknown    = 1
      object_not_found = 2
      OTHERS           = 3.


se61 den general text olarak yarat yarattıgını fonksiyona gonder





**** Mesaj Tipleri ***

A (Abend)
Termination
E (Error)
Error
I (Info)
Information
S (Status)
Status message
W (Warning)
Warning
X (Exit)
Termination with short dump

 message e000(yuauth) with text-025 gt_itab-value.

Total Pageviews