Sei sulla pagina 1di 6

*----------------------------------------------------------------------*

* *
* Programa..: ZIMACROS *
* Tipo......: INCLUDE *
* Mdulo....: BC *
* Descrio.: Global macros with usual routines for ABAP programs *
* Alteraes: *
* Data | Autor | Request | Descrio *
* 20/05/2010 | Edgar Oliveira | ********* | *
* *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Include ZIMACROS
*&---------------------------------------------------------------------*
"Icons library
INCLUDE <icon>.

************************************************************************
* TABELAS INTERNAS *
************************************************************************
*DATA:

************************************************************************
* VARIVEIS *
************************************************************************
DATA:
l_offset TYPE i. "Offset on page

************************************************************************
* Show a popup with prompt to confirm action *
* Ex: popup_confirma 'Deseja sair do pedido'
* l_pedido
* 'Saida do Pedido'
* l_resp.
************************************************************************
DEFINE popup_confirm.

call function 'POPUP_TO_CONFIRM_STEP'


exporting
defaultoption = 'N'
textline1 = &1
textline2 = &2
titel = &3
cancel_display = ''
importing
answer = &4.

if &4 = 'J'.
&4 = 'S'.
else.
&4 = 'N'.
endif.

END-OF-DEFINITION.

************************************************************************
* Fill range equal select options *
* EX: fill_range r_lifnr lfa1-lifnr ''.
************************************************************************
DEFINE fill_range.
"low <> space and high = space.
if not &2 is initial and &3 is initial.
find '*' in &2.
if sy-subrc eq 0.
&1-option = 'CP'.
else.
&1-option = 'EQ'.
endif.

&1-sign = 'I'.
&1-low = &2.
append &1.
"low = space and high <> space.
elseif &2 is initial and not &3 is initial.
find '*' in &3.
if sy-subrc eq 0.
&1-option = 'CP'.
else.
&1-option = 'EQ'.
endif.

&1-option = 'EQ'.
&1-sign = 'I'.
&1-low = &3.
append &1.
"low <> space and high <> space.
elseif not &2 is initial and not &3 is initial.
&1-option = 'BT'.
&1-sign = 'I'.
&1-low = &2.
&1-high = &3.
append &1.
endif.

END-OF-DEFINITION.

************************************************************************
* Fill bach-input screen *
* EX: bdc_dynpro 'SAPLM01' '0100' *
************************************************************************
DEFINE bdc_dynpro.
clear bdcdata.
bdcdata-program = &1.
bdcdata-dynpro = &2.
bdcdata-dynbegin = 'X'.
append bdcdata.
END-OF-DEFINITION.

************************************************************************
* Fill batch-input fields *
* EX: bdc_field 'EKKO-EBELN' '05000001' *
************************************************************************
DEFINE bdc_field.
clear bdcdata.
bdcdata-fnam = &1.
write &2 to bdcdata-fval.
append bdcdata.
END-OF-DEFINITION.

************************************************************************
* Get the icon code for insert icons in fields *
* EX: get_icon 'ICON_CHECKED' IT_SAIDA-ICON *
************************************************************************
DEFINE get_icon.
clear &2.
select single id into &2 from icon
where name = &1.
END-OF-DEFINITION.

************************************************************************
* Open simple log for report *
* Ex: OPEN_LOG. *
************************************************************************
DEFINE open_log.

get time.

format color col_heading intensified on.


uline.
write: /(170) '', 1 sy-title.
uline.
format color col_heading intensified off.
write: /(170) '', 1 'Usurio: ', sy-uname.
write: /(170) '', 1 'Data/Hora (incio)', sy-datum, '/', sy-uzeit.
uline.
format color col_normal intensified on.
write: /(170) '', 1 'Tp' , (20) 'Objeto', (67) 'Mensagem'.

END-OF-DEFINITION.

************************************************************************
* Add simple msg for log report *
* EX: add_log 'ICON_CHECKED' 'REMESSA' 'TESTES' *
************************************************************************
DEFINE add_log.
data:
begin of log occurs 0,
icon like icon-id,
obj(20),
texto(150),
end of log.

get_icon &1 log-icon.

log-obj = &2.
log-texto = &3.

format color col_normal intensified off.

write: /(170) '', 1 log-icon, log-obj, log-texto.

* append log.
END-OF-DEFINITION.
************************************************************************
* Close simple log report *
* Ex: close_log. *
************************************************************************
DEFINE close_log.

get time.

format color col_heading intensified off.


write: /(170) '', 1 'Data/Hora (fim)', sy-datum, '/', sy-uzeit.
uline.

END-OF-DEFINITION.

************************************************************************
* Show the progress in sap status bar *
* Ex: PROGRESS 50 'Registros Lidos'. *
************************************************************************
DEFINE progress.

call function 'SAPGUI_PROGRESS_INDICATOR'


exporting
percentage = &1
text = &2.

END-OF-DEFINITION.

*&---------------------------------------------------------------------*
*& Macro alpha2external
*& Convert alphanumeric number to the external number.
*& &1 - number internal format (e.g. 000001064263)
*& &2 - number external format (e.g. 1064263)
*&
*& alpha2external l_aennr $it_ecn-number.
*&---------------------------------------------------------------------*
DEFINE alpha2external.
" Convert to external format
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = &1
importing
output = &2
exceptions
length_error = 1
others = 2.

if sy-subrc <> 0.
write: / 'Erro ao converter o nmero', &1.
endif.

END-OF-DEFINITION. " alpha2external

*&---------------------------------------------------------------------*
*& Macro alpha2internal
*& Convert alphanumeric number to the SAP internal number.
*& &1 - number external format (e.g. 1064263)
*& &2 - number internal format (e.g 000001064263)
*&
*& alpha2internal $it_ecn-number l_aennr.
*&---------------------------------------------------------------------*
DEFINE alpha2internal.
" Convert to internal format
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = &1
importing
output = &2
exceptions
length_error = 1
others = 2.

if sy-subrc <> 0.
write: / 'Erro ao converter o nmero', &1.
endif.
" Ensure uppercase
translate &2 to upper case.

END-OF-DEFINITION. " alpha2internal

*&---------------------------------------------------------------------*
*& Macro divide_number
*& Divide two numbers and check for divition by zero.
*& &1 = &2 / &3
*&---------------------------------------------------------------------*
DEFINE divide_number.
if &3 = 0. " If divition by zero
&1 = 0. " Zero result
else.
&1 = &2 / &3. " Do the division
endif.
END-OF-DEFINITION. " divide_number

*&---------------------------------------------------------------------*
*& Macro submitPar
*& Add one record to SUBMIT parameter table.
*& &1 - Table with SUBMOIT parameters to add record to
*& &2 - Name of field in report to run
*& &3 - P = parameter, S = selection-option
*& &4 - I = include or E = exclude
*& &5 - Selection option: EQ, CP, GT, LT etc
*& &6 - Low or parameter value
*& &7 - High value for selction option
*& Example: submitPar it_par 'CN_PROJN' 'S' 'I' 'CP' 'PROJ-*' ''.
*&---------------------------------------------------------------------*
DEFINE submitpar.
&1-selname = &2.
&1-kind = &3.
&1-sign = &4.
&1-option = &5.
&1-low = &6.
&1-high = &7.
append &1.
END-OF-DEFINITION. " submitPar

*&---------------------------------------------------------------------*
*& Macro writeCenter
*& Print the given string at the center of current line.
*& Example: writeCenter 'COMPARING SALES ORDERS WITH BOM'.
*&---------------------------------------------------------------------*
DEFINE writecenter.
l_offset = strlen( &1 ) / 2.
l_offset = sy-linsz / 2 - l_offset.
write: at l_offset &1.
END-OF-DEFINITION. " writeCenter

*&---------------------------------------------------------------------*
*& Macro writePageNo
*& Print the page number on the right side of the page.
*& Example: writepageno.
*&---------------------------------------------------------------------*
DEFINE writepageno.
l_offset = sy-linsz - 8.
write: at l_offset 'Pgina' no-gap, (3) sy-pagno no-sign.
END-OF-DEFINITION. " writePageNo

*&---------------------------------------------------------------------*
*& Macro writeToday
*& Print the page number on the right side of the page.
*& Example: writepageno.
*&---------------------------------------------------------------------*
DEFINE writetoday.
l_offset = sy-linsz - 15.
write: at l_offset 'Data:', sy-datum.
END-OF-DEFINITION. " writeToday

Potrebbero piacerti anche