Escolar Documentos
Profissional Documentos
Cultura Documentos
Treinamento ABAP PDF
Treinamento ABAP PDF
NDICE
Curso Bsico
Data Dictionary
Transportes
Report
Performance
BDC Session
On Line
Sapscript
Smartform
Arquitetura 3 camadas
100 A 1
100 B 2
100 C 3
Tabela dependente de mandante
200 A 2
=
Primeira chave o mandante 200 B 3
200 D 4
300 C 2
Ttulo del documento | 4
CURSO BSICO
ORDENS DE TRANSPORTE
Dois tipos principais:
Configurao (customizing): dados, usualmente dependente
de mandante
Repositrio (workbench): levam contedo independente de
mandante (objetos do repositrio), mas podem levar dados,
inclusive os dependente de mandante.
Ordem aberta
Ordem fechada
Ordem
100 A 1
100 C 3
Exibir lista de objetos: exibe lista de projetos ligados ao programa (includes, tabelas,
telas, variveis, tabelas internas, etc).
Exibir janela de navegao: exibe pilha de navegao de objetos.
Ajuda online: exibe ajuda online da documentao do SAP.
Definir/eliminar ponto parada sesso: permite definir um ponto de parada para
depurao para a sesso ativa.
Definir/eliminar ponto parada externo: permite definir um ponto de parada para
depurao para uma chamada externa (RFC, por exemplo).
Modelo: permite incluir modelos de chamadas funes, mensagens, classes, etc.
Pretty Printer: efetua identao e efetua converses de maisculas e
minsculas de acordo com a configurao do editor.
Exemplo 1
REPORTZEXEMP_01.
WRITE:'111111'.
WRITE:'222222',
'333333'.
WRITE:/'111111'.
WRITE:15'333333'.
WRITE:/text-001.
ULINE.
ULINE8(6).
SKIP.
SKIP2.
WRITE:8sy-langu.
WRITE:/sy-datumUNDERsy-langu.
Exemplo 2
REPORTZEXEMP_02.
TOP-OF-PAGE.
WRITE:'EXEMPLO2-CURSOABAP/4',
80'Page',
SY-PAGNO.
Exemplo 3
REPORTZEXEMP_03.
FORMATCOLORCOL_HEADING.
WRITE:'FUNDOAZUL'.
Exemplo 4
REPORTZEXEMP_04.
DATA:nome(20)TYPEc,
rgTYPEi,
dataTYPEbkpf-budat,
hora(8)VALUE'14:05:45'.
MOVE'SolutionCenter'TOnome.
COMPUTErg=42159818+1.
data='19970530'."aaaammdd
Exemplo 5
REPORTZEXEMP_05.
PARAMETER:P_NOME1(15)TYPECOBLIGATORY,
P_NOME2(15)TYPECDEFAULT'Abap
Factory'LOWERCASE,
P_BOTAO1RADIOBUTTONGROUPG1,
P_BOTAO2RADIOBUTTONGROUPG1.
SELECT-OPTIONS:s_dataFORsy-datum.
Exemplo 6
REPORTZEXEMP_06.
DATA:ti_t005hTYPETABLEOFt005h,
wa_t005hTYPEt005h.
SELECT*
FROMt005h
INTOTABLEti_t005h
WHEREland1=p_pais
ANDspras=sy-langu
ORDERBYcityc.
Exemplo 7
REPORTZEXEMP_07.
LOOPATtg_t005hINTOwa_t005h.
ONCHANGEOFwa_t005h-land1.
IFv_var1=0.
NEW-PAGE.
ENDIF.
FORMATCOLOROFF.
WRITE'COUNTRYCITY'.
CLEARv_var1.
ENDON.
()
ENDLOOP.
Exemplo 8
REPORTZEXEMP_08.
CALLFUNCTION'GUI_DOWNLOAD'
EXPORTING
filename=v_arquivo
write_field_separator='X'
TABLES
data_tab=ti_spfli
EXCEPTIONS
file_write_error=1
no_batch=2
OTHERS=22.
Exemplo 9
REPORTZEXEMP_09.
CALLFUNCTION'GUI_UPLOAD'
EXPORTING
filename=vg_arquivo
TABLES
data_tab=tg_spfli
EXCEPTIONS
file_open_error=1
file_read_error=2
OTHERS=17.
IMPORTANTE
Ao salvar, indicar o pacote TRN e salvar.
O SAP pedir uma request, clique em e digite a seguinte descrio:
Academia de Talentos Grupo 01 Aluno ##
Anotar o nmero da change request para ser utilizado durante todo este curso
Atributos da transao
Atributos da transao
Cardinalidades
Formas Normais
Toda tabela deve ter pelo menos um campo chave, que ser
denominado chave primria
Nome: ZESTRUT_##
Descrio: Estrutura de preenchimento do layout
Nome: ZTBL_##
Descrio: Tabela para manuteno via transao SM30
1-) SELECT*FROMdbtab.
....
ENDSELECT.
ifSY-SUBRC<>
1a-)WHERECondition
1b-)ORDERBYf1fn
ORDERBYPRIMARYKEY
1c-)UPTOnROWS
2-) SELECT*FROMdbtabINTOTABLEitab.
2a-) WHERE
2b-) ORDERBY
2c-) UPTOnROWS
3-) SELECT*FROMdbtabAPPENDINGTABLEitab.
3a-) WHERE
3b-) ORDERBY
3c-) UPTOnROWS
4-) SELECTSINGLE*FROMdbtabINTOwaWHEREf1=
g1AND
5-) SELECT*FROMdbtabAPPENDINGCORRESPONDING
FIELDSOFTABLEitab.
5a-) SELECT*FROMdbtabINTOCORRESPONDINGFIELDSOF
TABLEitab.
6-) SELECT*FROMdtab
FORALLENTRIESINitabwhere
Nota: verificar se a tabela no est vazia, caso em que todos registros sero
selecionados
IFNOT(itab[]ISINITIAL).
SELECT*FROMdtabFORALLENTRIESinitab
wherecampo=itab-campo
ENDIF.
1 - SELECT*FROM<tabela>
2 - SELECT*FROM<tabela>WHERE<campo>EQ<var>
3 - SELECT*FROM<table>WHERE<tablefield>BETWEEN
<field1>and<field2>.
4 - SELECT*FROM<table>WHERE<tablefield>LIKE
._R%.
5 - SELECT*FROM<table>WHERE<tablefield>IN
(var1,var2).
6 - SELECT*FROM<table>WHERE<tablefield>IN
<internaltable>.
7 - SELECT*FROM<table>ORDERBY<field1>
<field2>PRIMARYKEY.
8 - SELECT*FROM<table>BYPASSINGBUFFER.
(Usado para ler diretamente da tabela original, e no do buffer).
9 - SELECT*FROM<table>APPENDINGTABLE
<internaltable>.
10 - SELECTFROM<table>INTOTABLE<INTERNAL
TABLE>.
11 - SELECT.INTOCORRESPONDINGFIELDSOFTABLE
<itab>.
12 - SELECT..APPENDINGCORRESPONDINGFIELDSOF
TABLE<itab>.
13 - SELECTSINGLE*FROMSPFLIWHERE
..<campo>..EQ<contedo>
14 - SELECT<a1><a2>INTO(<f1>,<f2>,)FROM
.<tabela>WHERE.
15 - SELECTMAX(campo)
MIN(campo)
AVG(campo)
COUNT(*)
FROM<table>INTO(..,,..,.)
WHERE.
16 - SELECT*FROMSFLIGHTWHEREPRICEINITAB.
17 - SELECT*FROM(<table>)INTO<workarea>.
Exemplo:
18- SELECT*FROM<table>FORALLENTRIESIN
<internaltable>WHERE
campo1=<contedo>and
campo2=<contedo>
19 - SELECTMIN(price)max(price)INTO
(minimum,maximum)FROMsflightWHERE...
19a - SELECTcarridMIN(price)max(price)
INTOTABLEitabFROMsflightWHERE
GROUPBYcarrid.
Arquivo de entrada:
Tipo de aeronave (1 linha por tipo)
Arquivo de sada:
Tipo de aeronave
; (separador fixo)
Companhia area
Ir para
Log de ao
Log de transporte
Tela 1000
Declarao de Variveis
Cabealho e Rodap
Declarao de Dados:
Include ZZIHEADR
Tabelas
Constantes e Variveis
Tabelas Internas
Parmetros de Entrada:
Select-Option
Parameters
Selection-screen
Ao Comando do Usurio:
At User-Command
At Line Selection
Cabealho e Rodap
Top-of-page
End-of-page
Exerccio 1
Exerccio 3
Pensando em performance
Acesso ao banco de dados
Manipulao dos dados
Caso particular de migraes
O banco
nico Rede e
estaes
Comunicao Banco
x Aplicao
Limitao nos
servidores de
aplicao
Principais cuidados:
No criar ndices demasiados para tabelas com muita
atualizao, pois os ndices degradam estas operaes.
Criar ndices disjuntos (campos distintos) e bem seletivos.
Levar em conta a semntica do campo.
Campo MANDT no necessrio (foi no passado)
Direct input
BAPI
iDoc Melhor
Call transaction performance
Pasta batch input
Estes mtodos podem ser utilizados via transao LSMW
ou diretamente a partir de programao
REPORTzxxxxxxx.
DATA:BEGINOFtbdcOCCURS100.
INCLUDESTRUCTUREbdcdata.
DATA:ENDOFtbdc.
*Inciodoprogramaprincipal
MOVEsapmf02kTOtbdc-program.
MOVE0100TOtbdc-dynpro.
MOVExTOtbdc-dynbegin.
APPENDtbdc.
MOVErf02k-lifnrTOtbdc-fnam.
MOVE0010010TOtbdc-fval.
APPENDtbdc.
MOVErf02k-ekorgTOtbdc-fnam.
MOVEcntlTOtbdc-fval.
APPENDtbdc.
BDC_INSERT
Chamada para cada transao no processamento Batch.
BDC_CLOSE_GROUP
Chamada aps todo processamento para que a pasta de
processamento Batch seja criada.
Funo BDC_OPEN_GROUP
Funo BDC_INSERT
Funo BDC_CLOSE_GROUP
Tela
Exibio (campos)
GUI-01
Mdulos PBO
Programa
Principal Screen 2 tela 2
GUI-02
Mdulos PBO
Screen 3 tela 3
Programa principal
Include TOP
LOOP AT SCREEN.
IF screen-group1 = 'G1'.
CLEAR screen-input.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
Em uma tabela:
SPFLI-CONNID Conexo
CITYFROM Origem
CITYTO Destino
Total de vos no intervalo de datas (pode ser zero)
Em uma tabela:
SFLIGHT-FLDATE
SFLIGHT-PRICE
SFLIGHT-CURRENCY
Dados
Formatao
Formulrio Sapscript
Abertura de um formulrio
Inicializao de um formulrio
Seleo dos dados do formulrio
Impresso dos dados nas janelas do formulrio
Finalizao do formulrio
Fechamento do formulrio
callfunction'OPEN_FORM'
exporting
DEVICE = 'PRINTER'
*DIALOG='X'
FORM = (Nome do Formulrio)
LANGUAGE = (Idioma do Formulrio)
OPTIONS=ITCPO
exceptions
canceled=1
device=2
form=3
options=4
unclosed=5
others=6.
callfunction'START_FORM'
exporting
FORM=''
LANGUAGE=''
exceptions
form=1
format=2
unended=3
unopened=4
unused=5
others=6.
callfunction'WRITE_FORM'
exporting
ELEMENT=''
WINDOW='MAIN'
exceptions
element=1
function=2
type=3
unopened=4
unstarted=5
window=6
others=7.
CALLFUNCTION'END_FORM'.
*IMPORTING
*RESULT=
*EXCEPTIONS
*UNOPENED = 1
* BAD_PAGEFORMAT_FOR_PRINT =2
*OTHERS=3
CALLFUNCTION'CLOSE_FORM'.
*IMPORTING
*RESULT=
*RDI_RESULT=
*TABLES
*OTFDATA=
*EXCEPTIONS
*UNOPENED=1
*BAD_PAGEFORMAT_FOR_PRINT=2
*SEND_ERROR=3
*OTHERS=4
Transao SE71
Traduzir formulrios
Janelas VAR
Dados podem mudar, durante o preenchimento do formulrio
Janelas CONST
Dados permanecem constantes aps o primeiro preenchimento.
IF..ELSE..ENDIF
CASE..WHEN
DEFINE
PERFORM..USING..CHANGING
BOX..FRAME
INCLUDE
Exemplo:
/: INCLUDE name OBJECT object ID id LANGUAGE spras
IL Linha de item
Atributos standard
Espacej.linhas 1.00 LN
Alinhamento Alinh.esq.
Tabuladores
6.00 CH Alinh. esquerda
25.00 CH Alinh. esquerda
54.00 CH Alinh. esquerda
73.00 CH Alinh. esquerda
Uso:
IL &EKPO-EBELP&,,&EKPO-EMATN&,,&EKPO-TXZ01&
DADOSDEVODACOMPANHIALH
_______________________________
RelatriodeVos
Companhia Vo Data
LH 0400 28.02.1995
LH 0454 17.11.1995
LH 9981 21.12.2002
independente de mandante.
CALLFUNCTION'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME='ZEXEMPLO_00'
IMPORTING
FM_NAME=V_SMART
EXCEPTIONS
NO_FORM=1
NO_FUNCTION_MODULE=2
OTHERS=3.
CALLFUNCTIONV_SMART
TABLES
T_SPFLI=T_SPFLI
T_SFLIGHT=T_SFLIGHT
T_SCARR=T_SCARR
T_SAPLANE=T_SAPLANE
EXCEPTIONS
FORMATTING_ERROR=1
INTERNAL_ERROR=2
SEND_ERROR=3
USER_CANCELED=4
OTHERS=5.