Funções Úteis:
CLAF_CLASSIFICATION_OF_OBJECT Retorna a classificação do material
CONVERSION_EXIT_CGCBR_INPUT Efetua a validação do código de CGC e CPF através do DC CONVERSION_EXIT_CUNIT_OUTPUT Converte um valor entre unidades sem necessitar do material CONVERSION_EXIT_PARVW_OUTPUT Faz a conversão de saída para o tipo de parceiro de cliente CONVERT_TO_LOCAL_CURRENCY Conversão de moeda
COPO_POPUP_TO_DISPLAY_TEXTLIST Popup para exibir várias linhas de texto
DATE_GET_WEEK Retorna a semana em que uma data se encontra
DAY_IN_WEEK Retorna o dia da semana de uma data.
Segunda = 1, Terça = 2, ..., Domingo = 7
DETERMINE_DUE_DATE Calcula a data de vencimento de uma duplicata. Fonte: \template\data_vencto.txt
DETERMINE_TXJCD_EXTERNALLY Determina o código de domicílio fiscal cliente
DYNP_VALUES_READ Captura o valor de um parâmetro para teste no caso de value-request.
Exemplo: fontes/ultrafertil/templates/dynp_values_read
FI_F4_ZTERM Chama matchcode de condição de pagamento
FIMA_DAYS_AND_MONTHS_AND_YEARS Transformar a diferença de duas datas em meses
GRAPH_MATRIX Gera uma window com graficos baseado em tabelas internas. HR_BR_CONVERT_ACCENTS Retira os acentos de uma string de texto
MESSAGE_PREPARE Monta uma mensagem com seus parametros
NUMBER_GET_ NEXT Retorna um novo número de uma number range. Grupo de função SNR3
PERIOD_AND_DATE_CONVERT_OUTPUT Converte uma data para o formato de saída passando período = 1. Para converter para o formato de gravação chamar a INPUT
POPUP_TO_CONFIRM Message box mais completo
POPUP_TO_CONFIRM_STEP Exibe box popup para confirmação de processamento POPUP_TO_CONFIRM_WITH_MESSAGE Exibe box popup para confirmação de processamento
POPUP_TO_DECIDE_LIST Apresenta uma tela com um radiobutton para cada linha de uma tabela interna passada como parâmetro. Permite escolher um dentre os itens da lista.
POSTAL_CODE_CHECK Efetua a validação do CEP
RP_LAST_DAY_OF_MONTHS Retorna último dia do mês
RP_PRINT_RT Imprime uma tabela cluster da folha
RS_LIST_SELECTION_TABLE Display items. Para impressão dos parâmetros de seleção de um report.
RS_REFRESH_FROM_SELECTOPTIONS Reads the values for the currently running report. Para impressão dos parâmetros de seleção de um report.
RS_VARIANT_CONTENTS Retorna o conteúdo de uma variante
SAPGUI_PROGRESS_INDICATOR Barra de indicação de progresso de processamento SET_PRINT_PARAMETERS Imprime os parâmetros de seleção de um report
SPELL_AMOUNT Retorna Valor por extenso
SXPG_CALL_SYSTEM Executa comandos externos no servidor
UNIT_CONVERSION_SIMPLE Converte um valor para uma unidade de medida Call function 'UNIT_CONVERSION_SIMPLE'
exporting
input = valor atual
round_sign = tipo de arredondamento ‘X’ unit_in = unidade atual
unit_out = unidade nova importing
output = valor convertido WS_FILE_DELETE Exclui um arquivo da estação de trabalho
Transações Úteis:
TRANSACAO
DESCRICAO
0FPM002
Importar Figura para ALV e Visualizador de Imagens
CMOD
Ativar uma EXIT ou criar um projeto(Menu, Customer e
Screen)
FB02
Modifica documento Contábil
FBL1N
Partidas indiv.fornecedores
FBRA
Anula compensação
NACW
Busca relacao programa/sapscript
OAER / OAOR
Importar uma figura *.gif
OBB8
Configuração da condicao de pagamento
PA03
Registro de Controle Folha Pgto
PC_PAYRESUL
T
Exibição dos result. da Folha Pgto
PC00_M37_CA
LC
Executa a Folha Pgto
PE01
Esquema da Folha Pgto
PE03
Feature - árvore de decisão
PE04
Atualização das Funções/Oper. da Folha Pgto
PFCG
Perfil
PU01
Eliminar resultado de cálculo da folha de pagamento
S_BCE_680012
86
Conversão
SARP
Abre arvore de relatórios
SCC1
Cópia entre mandantes no mesmo ambiente conforme
request
SCOT
Administração de fax, internet...
SD11
Modelagem de Dados
SE01
Exibir log de transporte de request p/ versões até 4.0
SE03
Exibir log de transporte de request p/ versões superior
a 4.0
SE09
Exibir Request - Desenv prog. {RELEASE p/ liberar}
SE10
Exibir Request - Cust. {RELEASE p/ liberar}
SE11
Dictionary
SE16
Visualização de Tabelas - Formato ALV List.
SE16N
Visualização de Tabelas - Formato ALV Grid.
SE18
Cria BADI
SE30
Verifica Performance
SE36
LOGICAL DATABASE
SE38
Editor ABAP
SE43
Atualização de Menu de Área
SE56
Atualizar Tabela
SE63
Tradução de programas
SE71
SAPSCRIPT
SE78
SAPSCRIPT-adm de gráficos
SE80
Repository(OnLine, Grupo de Função, classe, obj.
autorizacao,
classe mensagem, menus area, etc..)
SE93
Criar Transacao
SERP
Configura Árvore de Relatórios
SHDB
Mapeamento
SM04
Exibe informações de todos os usuários/tarefa
SM12
Exibe todos os objetos/tabelas bloqueados
SM13
Verifica erro na inclusao/alteracao de algum reg
SM30
Entrada de Dados em Tabelas
SM33
Visao de Pastas/verifica se o job já rodou
SM35
Rodar Pasta gerada em Batch Input(Gerenciamento de
Pastas)
SM36
Criar Jobs
SM37
Exibir todos os Jobs (Síntese e Alteração)
SM50
Exibe informações de todos os usuários
SM59
Verificar conexão do notes... Emails
SMX
Visualizar apenas seus Jobs (Monitorar)
SNOTE
Assistente de Aplicação Notas
SNRO
Intervalo de numeração
so00
SOSB
Email -conf
SOST
Relação dos emails enviados ou não
SP01
Exibir o SPOOL de impressão
SP02
Exibir o SPOOL de impressão
SPAD
Configurar Impressora
SPAU
Exibir objetos AD modificados
SQ03
Query
ST05
Debug Standers
ST22
Lista dos Dumps ocorridos
SU01
Atualizar cadastro do usuario
SU21
Objeto de Autorização
Modelo de Comentário Report:
*---* * *
* Empresa...: Nome da Empresa - Unidade de Negocios - SAP * * Cliente...: XXXXXXXXXXXXXXX *
* Programa..: XXXXXXXXXXXXXXX * * Tipo...: REPORT *
* Módulo....: Nome do modulo * * Transação.: XXXXXXXXXXX *
* Descrição.: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. * * Objetivo..: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX * * *
* *
* Autores...: Nome do ABAP * * Alterações: *
* Data | Autor | Request | Descrição *
* 08/06/2007 | Nome do Abap | ********* | Programa Inicial * * *
*---*
REPORT ******** LINE-SIZE 100 LINE-COUNT 65 NO STANDARD PAGE HEADING MESSAGE-ID XXX. ************************************************************************ * TABELAS TRANSPARANTES * ************************************************************************ * TABLES: ************************************************************************ * INCLUDE * ************************************************************************ * INCLUDE. ************************************************************************ * TELA DE SELEÇÃO * ************************************************************************ * SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-b01. * SELECT-OPTIONS:
* PARAMETERS:
* SELECTION-SCREEN END OF BLOCK b1.
************************************************************************ * VALIDAÇÃO DA TELA DE SELEÇÃO *
************************************************************************ * AT SELECTION-SCREEN. ************************************************************************ * INICIALIZAÇÃO * ************************************************************************ * INITIALIZATION. ************************************************************************ * INICIO DA ROTINA PRINCIPAL *
************************************************************************ * START-OF-SELECTION.
************************************************************************ * FIM DA ROTINA PRINCIPAL *
************************************************************************ * END-OF-SELECTION. ************************************************************************ * SUB-ROTINAS * ************************************************************************ ************************************************************************ * Form zf_seleciona *---* *
************************************************************************ ************************************************************************ * CABEÇALHO DA LISTA PRINCIPAL *
************************************************************************ * TOP-OF-PAGE.
************************************************************************ * CABEÇALHO DA LISTA SECUNDÁRIA *
************************************************************************ * TOP-OF-PAGE DURING LINE-SELECTION.
Modelo Comentário TOP INCLUDE:
*---* * *
* Empresa...: Nome da Empresa * * Programa..: ZIFI_REC_VAR * * Tipo...: INCLUDE * * Módulo....: FI *
* Descrição.: Tipos, Constantes e Variáveis Globais * * para XXXXXXXXXXXXXXX. * * Autor...: Nome do ABAP * * Alterações: *
* Data | Autor | Request | Descrição *
* 08/06/2007 | Nome do ABAP | ********** | Dicionário de Dados * * * *---* *&---* *& Include ************ * *&---* ************************************************************************ * TYPE-POOLS * ************************************************************************ * TYPE-POOLS: ************************************************************************ * CONSTANTES * ************************************************************************ * CONSTANTS: ************************************************************************ * TIPOS * ************************************************************************ * TYPES: ************************************************************************ * TABELAS INTERNAS * ************************************************************************ * DATA: ************************************************************************ * WORK AREA * ************************************************************************ * DATA: ************************************************************************ * VARIÁVEIS * ************************************************************************ * DATA: ************************************************************************ * RANGES * ************************************************************************ * RANGES:
Sites úteis sobre ABAP:
http://www.marceloperine.com.br/Abap/
http://www.abapfans.hpg.ig.com.br/sol.htm
Apostilas Microsiga: stelling.sites.uol.com.br
www.sapworld.hpg.ig.com.br/apostilas.html
http://www.sapgenie.com/abap/index.htm
https://www.sdn.sap.com/irj/sdn
http://help.sap.com
DICAS ABAP
BAPI´S
CRIAR LOTE
MODIFICAR LOTE
call function 'BAPI_BATCH_CHANGE' exporting material = p_material batch = p_batch plant = p_plant batchattributes = st_atributes batchattributesx = st_atributesx batchcontrolfields = st_batchctrl internalnumbercom = st_bncom extension1 = st_bncomz tables return = t_return.
GERA ROTEIRO STANDARD
data: it_task like bapi1190_tsk_c occurs 0 with header line, it_operation like bapi1190_opr_c occurs 0 with header line, it_return like bapiret2 occurs 0 with header line.
call function 'BAPI_REFSETOFOPERATIONS_CREATE' * EXPORTING * TESTRUN = '' * PROFILE = * BOMUSAGE = * APPLICATION = importing group = p_group groupcounter = p_count tables task = t_task * MATERIALTASKALLOCATION = operation = t_oper * SUBOPERATION = * COMPONENTALLOCATION = * PRODUCTIONRESOURCE = * INSPCHARACTERISTIC = * TEXTALLOCATION = * TEXT = return = it_return.
GERA NUMERO DE OBJETO INTERNO PARA SISTEMA DE CLASSIFICAÇÃO
* BAPI para gerar numero de objeto interno para sistema de classificacao * p_matnr = Material a ser classificado *
* p_plant = Centro do material * * p_batch = Lote do material *
* p_table = Tabela de referencia ao objeto, ex. MARA, MCHA * * p_class = Classe no sistema de classificacao do objeto * * p_create = Flag indicador para gerar numero objeto interno * * p_clobj = Numero interno do objeto no sistema de classificacao * *---*
form f_bapi_objcl_get_key_of_object using
p_matnr like bapibatchkey-material p_plant like bapibatchkey-plant p_batch like bapibatchkey-batch p_table like bapi1003_key-objecttable p_class like bapi1003_key-classtype p_create like bapi1003_key-flag
changing p_clobj like bapi1003_key-object_guid. data :lc_objectname like bapi1003_key-object.
lc_objectname+18(4) = p_plant. lc_objectname+22(10) = p_batch. clear: p_clobj,
it_bapiret2, it_bapiret2[].
call function 'BAPI_OBJCL_GET_KEY_OF_OBJECT' exporting objectname = lc_objectname objecttable = p_table classtype = p_class create_missing_key = p_create importing clobjectkeyout = p_clobj tables return = it_bapiret2. check not p_clobj is initial. perform f_bapi_commit_work.
endform. " f_bapi_objcl_get_key_of_object
CRIAR ORDEM DE VENDA
call function 'BAPI_SALESORDER_CREATEFROMDAT2' exporting * SALESDOCUMENTIN = order_header_in = st_bapisdhd1 order_header_inx = st_bapisdhd1x * SENDER = * BINARY_RELATIONSHIPTYPE = * INT_NUMBER_ASSIGNMENT = * BEHAVE_WHEN_ERROR = * LOGIC_SWITCH = testrun = p_testrun convert = p_convert importing salesdocument = p_salesdocument tables return = pt_return order_items_in = it_bapisditm order_items_inx = it_bapisditmx order_partners = it_bapiparnr order_schedules_in = it_bapischdl order_schedules_inx = it_bapischdlx order_conditions_in = it_bapicond * ORDER_CFGS_REF = * ORDER_CFGS_INST = * ORDER_CFGS_PART_OF = * ORDER_CFGS_VALUE = * ORDER_CFGS_BLOB = * ORDER_CFGS_VK = * ORDER_CFGS_REFINST = * ORDER_CCARD = * ORDER_TEXT = * ORDER_KEYS = extensionin = it_bapiparex * PARTNERADDRESSES = .
ESTORNA SAIDA DE MATERIAL EM ESTOQUE
call function 'BAPI_GOODSMVT_CANCEL' exporting materialdocument = p_materialdocument matdocumentyear = p_matdocumentyear * GOODSMVT_PSTNG_DATE = * GOODSMVT_PR_UNAME = importing goodsmvt_headret = t_bapi2017_gm_head_ret tables return = it_bapiret2 * GOODSMVT_MATDOCITEM = .
BAIXA DE MATERIAL EM ESTOQUE
call function 'BAPI_GOODSMVT_CREATE' exporting
goodsmvt_header = t_bapi2017_gm_head_01 goodsmvt_code = p_goddsmvt_code
testrun = p_testrun importing materialdocument = p_doc_mat tables goodsmvt_item = t_bapi2017_gm_item_create return = it_bapiret2.
CRIA CARACTERISTICAS PARA UM OBJETO
call function 'BAPI_OBJCL_CREATE_KEY' exporting clobjectkey_new = p_clobje classnum_new = p_class * STATUS = '1' * STANDARDCLASS = * CHANGENUMBER = * KEYDATE = SY-DATUM tables allocvaluesnum = t_values_num allocvalueschar = t_values_char * ALLOCVALUESCURR = return = it_bapiret2.
MODIFICA CARACTERISTICAS PARA OBJETO /CLASSE
call function 'BAPI_OBJCL_CHANGE_KEY' exporting clobjectkey = vc_clobjectkey classnum = vc_classnum tables allocvaluesnum_new = it_values_num allocvalueschar_new = it_values_char allocvaluescurr_new = it_values_curr return = it_return.
OBTEM CARACTERISTICAS PARA OBJETO E CLASSE
* Limpar característica reserva de estoque do lote vc_clobjectkey = p_objek.
vc_classnum = c_classe_lote.
call function 'BAPI_OBJCL_GETDETAIL_KEY' exporting clobjectkey = vc_clobjectkey classnum = vc_classnum keydate = sy-datum importing status = vc_status standardclass = vc_stdclass tables allocvaluesnum = it_values_num allocvalueschar = it_values_char allocvaluescurr = it_values_curr return = it_return.
read table it_values_char with key charact = c_reserva. if sy-subrc eq 0.
clear it_values_char-value_char. modify it_values_char index sy-tabix. endif.
ALTERA STATUS DE UMA OP
it_bapi_pp_timeticket-orderid = p_op. it_bapi_pp_timeticket-operation = p_operacao. it_bapi_pp_timeticket-fin_conf = p_fin_conf. it_bapi_pp_timeticket-postg_date = p_dt_ini. it_bapi_pp_timeticket-plant = p_werks. it_bapi_pp_timeticket-yield = p_metragem. it_bapi_pp_timeticket-scrap = p_scrap. it_bapi_pp_timeticket-conf_quan_unit = p_unidade. it_bapi_pp_timeticket-exec_start_date = p_dt_ini. it_bapi_pp_timeticket-exec_start_time = p_hr_inicio. it_bapi_pp_timeticket-exec_fin_date = p_dt_fim. it_bapi_pp_timeticket-exec_fin_time = p_hr_fim. it_bapi_pp_timeticket-work_cntr = p_centro_trab.
it_bapi_pp_timeticket-conf_activity1 = p_activity. it_bapi_pp_timeticket-conf_acti_unit1 = p_acti_unit1. append it_bapi_pp_timeticket.
call function 'BAPI_PRODORDCONF_CREATE_TT' * EXPORTING * POST_WRONG_ENTRIES = '0' * TESTRUN = * IMPORTING * RETURN = tables timetickets = it_bapi_pp_timeticket * GOODSMOVEMENTS = * LINK_CONF_GOODSMOV = detail_return = it_bapi_coru_return.
COMMIT E ROLLBACK PARA BAPI
call function 'BAPI_TRANSACTION_COMMIT'. call function 'BAPI_TRANSACTION_ROLLBACK'.
MODIFICA ORDEM DE VENDA
call function 'BAPI_SALESORDER_CHANGE' exporting salesdocument = p_salesdocument order_header_in = p_header order_header_inx = p_header_inx simulation = p_testrun tables order_item_in = pt_order_item_in order_item_inx = pt_order_item_inx partners = pt_partners partnerchanges = pt_partnerchanges partneraddresses = pt_partneraddresses schedule_lines = pt_schedule_lines schedule_linesx = pt_schedule_linesx order_text = pt_order_text conditions_in = pt_conditions_in conditions_inx = pt_conditions_inx extensionin = pt_extensionin return = pt_return.
INCLUI CONTRATO
call function 'BAPI_CONTRACT_CREATEFROMDATA' exporting contract_header_in = st_bapisdhd1 contract_header_inx = st_bapisdhd1x testrun = p_testrun convert = p_convert importing salesdocument = p_salesdocument tables return = pt_return contract_items_in = it_bapisditm contract_items_inx = it_bapisditmx contract_partners = it_bapiparnr contract_conditions_in = it_bapicond extensionin = it_bapiparex.
MODIFICA CONTRATO
call function 'BAPI_CUSTOMERCONTRACT_CHANGE' exporting salesdocument = p_salesdocument contract_header_in = p_header contract_header_inx = p_header_inx tables return = pt_return contract_item_in = pt_item contract_item_inx = pt_item_inx partners = pt_partners partnerchanges = pt_partnerchanges.
FUNÇÕES DIALOG
DIALOG BOX – ENTRADA DE VALORES
DATA it_sval like sval occurs 0 with header line, it_sval-tabname = 'CRHD' ** Tabela
it_sval-fieldname = 'WERKS'. ** Nome do Campo it_sval-fieldtext = 'Centro'. ** Descrição do campo append it_sval.
call function 'POPUP_GET_VALUES' exporting no_value_check = ' ' popup_title = text-t11 start_column = '5' start_row = '5' importing returncode = vc_valor_digitado tables fields = it_sval exceptions error_in_fields = 1 others = 2.
DIALOG BOX PARA CONFIRMAÇÃO DE UM PROCESSO
call function 'POPUP_TO_CONFIRM_WITH_MESSAGE' exporting
defaultoption = 'Y'
diagnosetext1 = vl_diagnosetext1 textline1 = 'Deseja continuar ?'
titel = 'Consistência Centro de Trabalho' start_column = 25 start_row = 6 cancel_display = 'X' importing answer = vl_resp. if vl_resp ne 'J'. leave screen. set screen 0. endif.
DIALOG BOX (pode ser configurada)
call function 'POPUP_FOR_INTERACTION' exporting
headline = 'Estorno processamento 1'
text1 = 'Lançamento selecionado será estornado' text2 = 'Deseja realmente estorná-lo?'
ticon = 'I'
button_1 = 'Cancelar' button_2 = 'Confirmar' importing
button_pressed = vc_button.
DIALOG BOX(CANCEL – SIM – NÃO)
call function 'POPUP_TO_CONFIRM_STEP' exporting defaultoption = 'N' textline1 = text-m04 textline2 = text-m05 titel = text-m03 importing answer = vc_resp exceptions others = 01.
FUNÇÕES – Obter dados
OBTEM DADOS DA EMPRESA CNPJ...
J_1B_BRANCH_READ
OBTEM HISTORICO DO PAGAMENTO
call function 'CUSTOMER_PAYMENT_HISTORY' exporting
i_kkber = it_bsad_abert-kkber i_kunnr = it_bsad_abert-kunnr tables
t_knb4 = it_t_knb4.
OBTEM STATUS DE UM OBJETO(CODIGO)
data: it_jstat like jstat occurs 0 with header line. call function 'STATUS_READ'
exporting client = sy-mandt objnr = vc_objnr only_active = 'X' tables status = it_jstat exceptions object_not_found = 1 others = 2.
OBTEM STATUS DE UM OBJETO (TEXTO)
* Recuperar status da OP
call function 'STATUS_TEXT_EDIT' exporting client = sy-mandt objnr = vc_objnr only_active = 'X' spras = 'P' importing line = vc_status_op exceptions object_not_found = 1 others = 2.
OBTEM TEXTO DA ORDEM
* Verifica se existe texto da ordem select single tdobject
into stxh-tdobject from stxh
where tdobject = 'VBBK' and tdname = it_vbak-vbeln and tdid = 'ZCTS'
and tdspras = sy-langu. if sy-subrc eq 0.
call function 'READ_TEXT' exporting client = sy-mandt id = 'ZCTS' language = sy-langu name = vc_tdname object = 'VBBK' tables lines = it_texto_ordem.
OBTER VALORES DE UM DOMINIO
call function 'DD_DOMVALUES_GET' exporting domname = p_nome langu = sy-langu tables dd07v_tab = it_values exceptions wrong_textflag = 1
others = 2.
OBTEM DADOS MRP
* Obtem Dados de cabeçalho - documento MRP clear pendencias-matnr.
SELECT single matnr dtnum cflag FROM mdkp INTO (pendencias-matnr, pendencias-dtnum, pendencias-CFLAG) WHERE dtart = 'MD' AND matnr = v_matnr AND plwrk = centro AND plscn = 0.
CALL FUNCTION 'READ_MRP_LIST' EXPORTING
IDTNUM = pendencias-dtnum ICFLAG = pendencias-CFLAG TABLES
MDTBX = it_MDTB
VERIFICA STATUS DA ORDEM VENDA
call function 'SD_CREDIT_REFRESH' exporting
check_no_refresh = c_off.
call function 'SD_ORDER_CREDIT_RELEASE' exporting
vbeln = p_vbeln exceptions
error_message = 4.
VERSAO PRODUÇÃO
call function 'CP_DB_PLAS_READ' exporting plnal = t_mkal-plnal plnnr = t_mkal-plnnr plnty = t_mkal-plnty tables planas = t_paux exceptions no_records = 1 others = 2.
OBTEM DADOS DO MATERIAL
call function 'MARA_READ' exporting i_matnr = p_matnr i_sprache = sy-langu importing e_makt = p_makt e_mara = p_mara exceptions no_entry = 1 others = 2.
OBTEM STATUS DA ORDEM
call function 'STATUS_TEXT_EDIT' exporting client = sy-mandt objnr = t_aufk-objnr only_active = 'X' spras = sy-langu importing line = lc_status exceptions object_not_found = 1 others = 2.
RETORNA IMPRESSORA DEFAULT DO WINDOWS
'RSPO_FRONTEND_PRINTERS_FOR_DEV'
FUNÇÕES – Arquivos
Informando a data e um numero 6 devolve o sexto dia util
DAY_ATTRIBUTES_GET
com os parametros
FACTORY_CALENDAR = '01'
HOLIDAY_CALENDAR = '01'
DATE_FROM =
DATE_TO =
LANGUAGE =
Será retornada uma tabela interna com todos os dias solicitados. Olhe a
coluna HOLIDAY (feriado) e FREEDAY (fim de semana).
LEITURA DE ARQ E ATAUALIZA TABELA INTERNA
call function 'WS_UPLOAD' exporting filename = p_arq tables data_tab = it_arq exceptions conversion_error = 1 file_open_error = 2 file_read_error = 3 invalid_type = 4 no_batch = 5 unknown_error = 6 invalid_table_width = 7 gui_refuse_filetransfer = 8 customer_error = 9 others = 10.
VERIFICA SE ARQUIVO EXISTE
call function 'WS_QUERY' exporting filename = p_arq query = 'FE' importing return = vc_return exceptions inv_query = 1 no_batch = 2 frontend_error = 3 others = 4.
SELEÇÃO ARQUIVO
* Busca nome de arquivo
at selection-screen on value-request for p_arq. call function 'KD_GET_FILENAME_ON_F4' changing
file_name = p_arq.
LEITURA ARQUIVO
call function 'WS_FILENAME_GET' exporting
def_filename = 'log_ZSD03.txt' def_path = 'C:\Temp\' mask = ',*.*,*.*.' mode = 'O'
title = 'Seleção do Arquivo' importing filename = p_namfil exceptions inv_winsys = 1 no_batch = 2 selection_cancel = 3 selection_error = 4 others = 5.
GERA ARQ TXT A PARTIR TABELA INTERNA
call function 'DOWNLOAD' exporting filename = lc_name filetype = 'ASC' filemask_text = lc_mask filetype_no_change = 'X' tables data_tab = it_log exceptions invalid_filesize = 1 invalid_table_width = 2 invalid_type = 3 no_batch = 4 unknown_error = 5 gui_refuse_filetransfer = 6 others = 7.
Ver WS_DOWNLOAD, 'LIST_DOWNLOAD'
OUTRAS FUNÇÕES
MENSAGEM NO RODAPÉ - STATUS DOS PROCEDIMENTOS
perform send_gui(saplcozf) using text-010.
LOGON DO USUÁRIO
data: lc_answer like sy-ucomm, lc_senha like xu400-newcode.
call function 'SUSR_USER_SURFACE_PASSWORD' importing
password = lc_senha okcode = lc_answer.
SCROLLING IN TABLE CONTROL
(
Geralemnte Utilizado 'P--' or 'P-' or 'P+' or 'P++'.) form compute_scrolling_in_tc using p_tc_name p_ok.*-BEGIN OF LOCAL DATA---* data l_tc_new_top_line type i.
data l_tc_name like feld-name. data l_tc_lines_name like feld-name. data l_tc_field_name like feld-name. field-symbols <tc> type cxtab_control. field-symbols <lines> type i.
*-END OF LOCAL DATA---* assign (p_tc_name) to <tc>.
* get looplines of TableControl
concatenate 'G_' p_tc_name '_LINES' into l_tc_lines_name. assign (l_tc_lines_name) to <lines>.
* is no line filled? * if <tc>-lines = 0. * yes, ... * l_tc_new_top_line = 1. else. * no, ... * call function 'SCROLLING_IN_TABLE'
exporting entry_act = <tc>-top_line entry_from = 1 entry_to = <tc>-lines last_page_full = 'X' loops = <lines> ok_code = p_ok overlapping = 'X'
importing entry_new = l_tc_new_top_line exceptions no_entry_or_page_act = 01 no_entry_to = 02 no_ok_code_or_page_go = 03 others = 99. 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.
endif.
* get actual tc and column * get cursor field l_tc_field_name
area l_tc_name. if syst-subrc = 0.
if l_tc_name = p_tc_name.
* set actual column * set cursor field l_tc_field_name line 1.
endif. endif.
* set the new top line * <tc>-top_line = l_tc_new_top_line.
endform. " compute_scrolling_in_tc
CONVERTER MOEDA ESTRANGEIRA
call function 'CONVERT_TO_LOCAL_CURRENCY' exporting client = sy-mandt date = sy-datum foreign_amount = p_foreign_amount foreign_currency = 'USD' local_currency = 'BRL' rate = 0 type_of_rate = 'M' read_tcurr = 'X' importing local_amount = vp_local_amount exceptions no_rate_found = 1 overflow = 2 no_factors_found = 3 no_spread_found = 4 derived_2_times = 5 others = 6.
OBTEM NUMERO(ATINN) DA CLASSIFICAÇÃO
* BUSCA O NÚMERO DO ATINN DE ACABAMENTO call function 'CONVERSION_EXIT_ATINN_INPUT' exporting
input = 'TIPODEACABAMENTO' importing
output = vc_atinn_qualidade.
LISTA CAMPOS DA TELA
call function 'GET_DYNPRO_LIST' exporting
dyname = ls_prog_name dynumb = ln_dynp_num tables
dynpro_list = it_dynpro_list. call function 'ALV_LIST_SORTING_DEFINE' exporting
i_control = ls_control it_fieldcatalog = lt_fieldcat
i_type = p_listtype changing ct_sort = p_rt_sort[] exceptions no_change = 1 others = 2.
ENCONTRA PROXIMO DIA UTIL
call function 'DATE_CONVERT_TO_FACTORYDATE' exporting correct_option = '+' date = it_bsid-dt_venc factory_calendar_id = 'ZF' importing date = vd_dat_retorno * FACTORYDATE = * WORKINGDAY_INDICATOR = exceptions calendar_buffer_not_loadable = 1 correct_option_invalid = 2 date_after_range = 3 date_before_range = 4 date_invalid = 5 factory_calendar_not_found = 6 others = 7 . if sy-subrc <> 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. endif.SOMA/SUB DIA, MESES, ANOS DE UMA DATA
Veja a função RP_CALC_DATE_IN_INTERVAL ....
Nesta funcao, vc pode somar dias, meses, e anos.
Tanto pode somar como subtrair ( Campo Signum com + ou - ) ...
OBTEM QUANTIDADE DE MESES ENTRE 2 DATAS
call function 'MONTHS_BETWEEN_TWO_DATES' exporting i_datum_bis = ult i_datum_von = pri * i_kz_incl_bis = i_kz_incl_bis importing e_monate = vc_quantmeses.CALCULO DIGITO VERIFICADOR INSCRIÇÃO ESTADUAL
http://www.sef.sc.gov.br/consulta/rotinacritica/rotinaie/calcdigverificIE.htm
http://www.abapfans.hpg.com.br/sol/sol0036.htm
OBTEM PROXIMO NUMERO NO INTERVALO DE NUMERAÇÃO
call function 'NUMBER_GET_NEXT' exporting nr_range_nr = '01' object = 'ZNR_BANC' importing number = p_num_ord exceptions interval_not_found = 1 number_range_not_intern = 2 object_not_found = 3 quantity_is_0 = 4 quantity_is_not_1 = 5 interval_overflow = 6 others = 7.ROTINA CONVERSÃO MOEDA
call function 'CONVERT_CURRENCY_BY_RATE' exporting
from_amount = vl_valor from_currency = it_tcurr-fcurr from_factor = it_tcurf-ffact rate = it_tcurr-ukurs to_currency = p_waers to_factor = it_tcurf-tfact importing to_amount = vl_conv exceptions no_rate_found = 1 others = 2.
EXIBE VALORES TELA TIPO MATCH CODE
* Denominação
it_fields-tabname = 'TSPAT'. it_fields-fieldname = 'VTEXT'. it_fields-selectflag = ' '. append it_fields.
call function 'HELP_VALUES_GET_WITH_TABLE' exporting
titel = 'Setor de Atividade' importing
select_value = p_spart-low tables
fields = it_fields valuetab = it_valuetab.
OBTER ULTIMO DIA DO MES
if p_data is initial.
call function 'RP_LAST_DAY_OF_MONTHS' exporting day_in = sy-datum importing last_day_of_month = p_data exceptions day_in_no_date = 1 others = 2. if sy-subrc <> 0. clear sy-subrc. endif. endif.
RETORNA DATA POR EXTENSO
DAY_ATTRIBUTES_GET
RETIRA CARACTERES ESPECIAIS DE UMA ROTINA
call function 'HR_BR_CONVERT_ACCENTS' exporting
in_text = it_lfa1-name1 sw_strip_dot = ' '
importing
out_text = it_lfa1-name1.
RECUPERA DESCRIÇÃO DA MENSAGEM
call function 'RH_MESSAGE_GET' exporting sprsl = p_msgspra arbgb = p_msgid msgnr = p_msgnr msgv1 = ' ' msgv2 = ' ' msgv3 = ' ' msgv4 = ' ' importing msgtext = lc_texto exceptions message_not_found = 1 others = 2. if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. endif.
MONTAR TABLE CONTROL
data: it_nametab like dfies occurs 0 with header line, it_fieldif like field_dif occurs 0 with header line. * Itens do TableControl
data: begin of it_line occurs 0, check,
vbeln like vbap-vbeln, name1 like kna1-name1, posnr like vbap-posnr, matnr like vbap-matnr, bmeng like vbep-bmeng, vtweg like vbak-vtweg, spart like vbap-spart, zzreg_555 like vbap-zzreg_555, zzreg_abc like vbap-zzreg_abc, zznum_pto like vbap-zznum_pto, zztip_ins like vbap-zztip_ins, idreg_555(7),
idreg_abc(7), idnum_pto(7), idtip_ins(7), end of it_line.
data: it_record like it_line occurs 0 with header line. it_record[] = it_line[]. clear it_nametab. it_nametab-tabname = p_tabname. it_nametab-fieldname = p_fieldname. it_nametab-position = p_position. it_nametab-offset = p_offset. it_nametab-leng = p_leng. it_nametab-intlen = p_leng. it_nametab-outputlen = p_outleng. it_nametab-datatype = p_datatype. it_nametab-inttype = p_inttype. it_nametab-reptext = p_reptext. it_nametab-keyflag = p_keyflag. append it_nametab. clear it_fieldif. it_fieldif-tabname = p_tabname. it_fieldif-fieldname = p_fieldname. it_fieldif-no_input = 'X'. it_fieldif-fixed_col = ' '. append it_fieldif. * Campos especiais
delete it_fieldif where fieldname = 'UMSKS'. delete it_fieldif where fieldname = 'LFREL'. clear it_fieldif. it_fieldif-tabname = 'BSID'. it_fieldif-fieldname = 'UMSKS'. it_fieldif-fixed_col = 'X'. it_fieldif-icon = 'X'. append it_fieldif. clear it_fieldif. it_fieldif-tabname = 'VBEP'. it_fieldif-fieldname = 'LFREL'. it_fieldif-checkbt = 'X'. it_fieldif-no_fky_chk = 'X'. it_fieldif-fixed_col = 'X'. append it_fieldif.
call function 'STC1_POPUP_WITH_TABLE_CONTROL' exporting header = text-022 tabname = ' ' display_only = ' ' endless = ' ' * DISPLAY_TOGGLE = * SORT_FORBIDDEN = * MODIFY_CHECK = * INSERT_CHECK = * DELETE_CHECK = * MODIFY_DISP_FIELD = * NO_INSERT = * NO_DELETE = * NO_MOVE = * NO_UNDO = no_button = ' ' x_start = 22 y_start = 3 x_end = 106 y_end = 22 tables nametab = it_nametab table = it_record fielddif = it_fieldif exceptions no_more_tables = 1 too_many_fields = 2 nametab_not_valid = 3 handle_not_valid = 4 others = 5. case sy-ucomm. when 'OK'. * Identificar linhas selecionadas it_line-check = c_off. modify it_line transporting check where check = c_on. loop at it_record where check = c_off. it_line-check = c_on. modify it_line index sy-tabix transporting check. endloop. loop at it_line where check = c_on. it_vbap-idprc = c_criv. modify it_vbap transporting idprc where vbeln = it_line-vbeln and posnr = it_line-posnr. endloop. when 'CANC'. stop. endcase.
ENVIA MENSAGEM PARA DETERMINADO USUÁRIO
call function 'TH_POPUP' exporting client = sy-mandt user = it_bloqueio-uname message = vc_message message_len = 999 cut_blanks = c_on exceptions user_not_found = 1 others = 2.SO_NEW_DOCUMENT_SEND_API1
Envia Mensagem para for a SAP - Outlook
ENVIA MENSAGEM COM LISTA DE VALORES
* Montar estrutura
it_fields-tabname = 'VBAK'. it_fields-fieldname = 'VBELN'.
append it_fields. it_fields-tabname = 'KNA1'. it_fields-fieldname = 'NAME1'. append it_fields. it_fields-tabname = 'VBAK'. it_fields-fieldname = 'VKORG'. append it_fields. it_fields-tabname = 'VBAK'. it_fields-fieldname = 'ERNAM'. append it_fields.
call function 'POPUP_TO_SHOW_DB_DATA_IN_TABLE' exporting title_text = text-m02 tables fields = it_fields valuetab = it_valuetab exceptions field_not_in_ddic = 1 others = 2.
OBTEM DESCRIÇÃO DA MENSAGEM
call function 'MESSAGE_PREPARE' exporting language = sy-langu msg_id = msg_id msg_no = msg_no msg_var1 = msg_var1 msg_var2 = msg_var2 msg_var3 = msg_var3 msg_var4 = msg_var4 importing msg_text = msg_text exceptions function_not_completed = 1 message_not_found = 2 others = 3.
FUNÇÃO PARCEIRO
call function 'CONVERSION_EXIT_PARVW_INPUT' exporting
input = pt_vbpa-parvw importing
output = it_bapiparnr-partn_role.
ENVIA MENSAGEM
SAPOFFICE* Envia mensagem SAPOFFICE para responsavel por planejamento corte, * * se planejar fora da sequencia especificada *
form f_send_sapoffice tables t_user structure t100c t_objcont structure soli
t_objhead structure soli
using p_titulo like sos03-s_objdes p_acnam like sood1-acnam. data: st_object_hd_change like sood1.
data: t_receivers like soos1 occurs 0 with header line. * Estrutura mensagem
st_object_hd_change-objla = sy-langu. "Idioma
st_object_hd_change-objnam = 'MENSAGEM'. "Nome documento st_object_hd_change-objdes = p_titulo. "Título
st_object_hd_change-objpri = '1'. "Prioridade de documento st_object_hd_change-objsns = 'F'. "Objeto: sensibilidade st_object_hd_change-objcp = 'X'. "Objeto não pode ser modif. st_object_hd_change-vmtyp = 'T'. "Executar: (report, dlg... st_object_hd_change-skips = 'X'. "Executar: 1a.tela em backg
st_object_hd_change-acnam = p_acnam. "Executar: nome (report,... * Destinatário
clear t_receivers. refresh t_receivers.
t_receivers-rcdat = sy-datum. "Data recebimento documento t_receivers-rctim = sy-uzeit. "Hora recebimento documento t_receivers-sndex = 'X'. "Enviar: como expresso
loop at t_user.
t_receivers-recnam = t_user-uname. "Nome do destinatário t_receivers-rtunam = t_user-uname. "Nome do destinatário append t_receivers.
endloop.
call function 'SO_OBJECT_SEND' exporting object_hd_change = st_object_hd_change object_type = 'RAW' owner = sy-uname tables objcont = t_objcont * objhead = it_objhead * OBJPARA = IT_OBJPARA * OBJPARB = IT_OBJPARB receivers = t_receivers exceptions active_user_not_exist = 1 communication_failure = 2 component_not_available = 3 folder_not_exist = 4 folder_no_authorization = 5 forwarder_not_exist = 6 note_not_exist = 7 object_not_exist = 8 object_not_sent = 9 object_no_authorization = 10 object_type_not_exist = 11 operation_no_authorization = 12 owner_not_exist = 13 parameter_error = 14 substitute_not_active = 15 substitute_not_defined = 16 system_failure = 17 too_much_receivers = 18 user_not_exist = 19 x_error = 20 others = 21. check sy-subrc <> 0.
message e398(00) with text-e21 '' '' ''. endform. " f_send_sapoffice
EXIBE VALORES EM TELA (Util Match Code)
data: begin of t_shstruc occurs 1. include structure shstruc. data: end of t_shstruc.
data: begin of t_shvalue occurs 1. include structure shvalue. data: end of t_shvalue.
data: ln_value like help_info-fldvalue.
clear: t_shvalue[], t_shvalue, t_shstruc[], t_shstruc. select matnr
maktx into table t_makt
from makt for all entries in t_stpo where matnr = t_stpo-idnrk and
spras = sy-langu.
sort t_makt by matnr ascending. loop at t_stpo.
read table t_makt with key matnr = t_stpo-idnrk binary search. check sy-subrc = 0. t_shvalue-line = sy-tabix. t_shvalue-pos = 1. t_shvalue-low_value = t_stpo-idnrk. append t_shvalue. t_shvalue-pos = 2. t_shvalue-low_value = p_werks. append t_shvalue. t_shvalue-pos = 3. t_shvalue-low_value = t_makt-maktx. append t_shvalue. endloop. t_shstruc-pos = 1. t_shstruc-tabname = 'STPO'. t_shstruc-fieldname = 'IDNRK'. t_shstruc-fieldtype = 'CHAR'. t_shstruc-fieldlen = 000018. t_shstruc-keyword = text-e13. t_shstruc-selectflag = 'X'. append t_shstruc. t_shstruc-pos = 2. t_shstruc-tabname = 'T001W'. t_shstruc-fieldname = 'WERKS'. t_shstruc-fieldtype = 'CHAR'. t_shstruc-fieldlen = 000004. t_shstruc-keyword = text-e01. t_shstruc-selectflag = ' '. append t_shstruc. t_shstruc-pos = 3. t_shstruc-tabname = 'MAKT'. t_shstruc-fieldname = 'MAKTX'. t_shstruc-fieldtype = 'CHAR'. t_shstruc-fieldlen = 000040. t_shstruc-keyword = text-028. t_shstruc-selectflag = ' '. append t_shstruc.
call function 'VALUES_DISPLAY' exporting cucol = 1 curow = 1 fieldname = 'STPO' tabname = 'IDNRK' importing select_value = ln_value tables values = t_shvalue valuestructure = t_shstruc exceptions check_table_locked = 1 no_values_for_field = 2 tablefield_does_not_exist = 3 others = 4. if sy-subrc = 0. p_matnr = ln_value. endif.
OBTEM CAMPO DE TELA(Util Match Code)
"-->Tabela para receber campos lidos de uma tela
data: it_dynpread like dynpread occurs 0 with header line. it_dynpread-fieldname = 'ZPPT010-WERKS'.
call function 'DYNP_VALUES_READ' exporting dyname = 'SAPMZPP009' dynumb = sy-dynnr tables dynpfields = it_dynpread exceptions invalid_abapworkarea = 1 invalid_dynprofield = 2 invalid_dynproname = 3 invalid_dynpronummer = 4 invalid_request = 5 no_fielddescription = 6 invalid_parameter = 7 undefind_error = 8 double_conversion = 9 stepl_not_found = 10 others = 11.
RECUPERA PROXIMO NUMERO SEQUENCIAL DISPONIVEL
call function 'NUMBER_GET_NEXT' exporting nr_range_nr = '01' object = 'Z_LOTE' quantity = '1' importing number = p_batch exceptions interval_not_found = 1 number_range_not_intern = 2 object_not_found = 3 quantity_is_0 = 4 quantity_is_not_1 = 5 interval_overflow = 6 others = 7.
MENSAGEM
data: it_message like bdcmsgcoll occurs 0 with header line. call function 'MESSAGE_TEXT_BUILD'
exporting msgid = it_message-msgid msgnr = it_message-msgnr msgv1 = it_message-msgv1 msgv2 = it_message-msgv2 msgv3 = it_message-msgv3 msgv4 = it_message-msgv4 importing message_text_output = lc_mess.
MODIFICA CONTEUDO DA TELA
data: t_dynpread like dynpread occurs 0 with header line. t_dynpread-fieldname = 'ZPPT010-QTDE_BOB'. t_dynpread-fieldvalue = zppt010-qtde_bob. append t_dynpread.
"--> Atualiza campos da tela call function 'DYNP_VALUES_UPDATE' exporting dyname = 'SAPMZPP009' dynumb = sy-dynnr tables dynpfields = t_dynpread .
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'IT_DIAUTIL-DATA'
dynpprog = sy-cprog
dynpnr = '9170'
window_title = text-067
value_org = 'S'
tables
value_tab = it_diautil
exceptions
others = 3.
observações:
retfield = nome da tabela e campo da sua tabela interna,
dynpprog = nome do programa
dynpnr = numero da tela
window_title = texto no cabeçalho do matchode
Value_tab = tabela interna.
F4IF_FIELD_VALUE_REQUEST ver include LKOBSF6U
CONVERTE UNIDADE DE MEDIDA
call function 'CONVERSION_EXIT_CUNIT_OUTPUT' exporting input = wa_mara-meins language = sy-langu importing output = vc_meins exceptions unit_not_found = 1 others = 2.
OBTEM MESSAGEM RETORNADA PELA SAP (Ex: Num ordem criada)
call function 'MESSAGE_TEXT_BUILD' exporting msgid = it_message-msgid msgnr = it_message-msgnr msgv1 = it_message-msgv1 msgv2 = it_message-msgv2 msgv3 = it_message-msgv3 msgv4 = it_message-msgv4 importing message_text_output = lc_mess.
OBTEM VALOR POR EXTENSO
CALL FUNCTION 'SPELL_AMOUNT' EXPORTING amount = j_1bprnfhd-nftot currency = 'BRL' filler = ' ' language = sy-langu IMPORTING in_words = spell EXCEPTIONS not_found = 1 too_large = 2 OTHERS = 3.
OBTEM VALOR DE UM CAMPO NA TELA
form monta_bukrs_pc.
data : begin of t_get occurs 0.
include structure dynpread.
data : end of t_get.
t_get-fieldname = 'EKPO-BUKRS'. " EMPRESA
append t_get.
t_get-fieldname = 'EKPO-KNTTP'. " CATEGORIA CLASS CONT
append t_get.
exporting
dyname = 'SAPMM06E'
dynumb = '0113'
tables
dynpfields = t_get
exceptions
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
others = 11.
if sy-subrc ne 0.
message e398(00) with 'Zillo-Exit(wempf) E R R O '
'Funcao Valor de Tela PC - Subrc = ' sy-subrc.
else.
clear t_get.
read table t_get with key fieldname = 'EKPO-BUKRS'.
wbukrs = t_get-fieldvalue.
clear t_get.
read table t_get with key fieldnam e = 'EKPO-KNTTP'.
wknttp = t_get-fieldvalue.
endif.
PROGRAMA SEJA EXECUTADO EM BACKGROUND
DATA: C_REPORT LIKE RALDB-REPORT.
C_REPORT = 'ZREPORT'. " report a ser executado em background
CALL DIALOG 'JOB_SUBMIT'
EXPORTING
RALDB-REPORT FROM C_REPORT.
COMANDO DE CONTROLE - SAPSCRIPT
ADDRESS Formatação automática de informação de endereço
BOTTOM Usado apenas na janela MAIN para imprimir no rodapé da janela
BOX Cria caixa
CASE Cria condição para argumentos
DEFINE Cria um novo símbolo em tempo de execução
HEX Passa valores hexadecimais diretamente
IF Cria condição para argumentos
INCLUDE Incluí outros textos e logotipos
NEW-PAGE Força uma nova página
NEW-WINDOW Força uma nova janela
PERFORM Chama subrotina
POSITION Usado para caixas setando X & Y
PRINT-CONTROL Inicializa um seqüência definida de controle de impressão
PROTECT Protege uma página de parada
RESET Reestarta seqüência de números de saída
SET COUNTRY Seta o país para campos
SET DATE MASK Seta formato de data
SET SIGN Coloca o campo a direita ou esquerda do número
SET TIME MASK Seta formato de hora
SIZE Usado apenas para caixa onde seta o tamanho da caixa
STYLE Usa um diferente tipo de estilo
SUMMING Adiciona valores para um total
TOP Usado apenas na janela MAIN para imprimir no topo da janela
Procure montar o comando box definindo a espessura da linha, através do parâmetro "frame",
cf. exemplo abaixo:
BOX XPOS 000 MM YPOS 000 MM WIDTH 170 MM HEIGHT 10 MM FRAME 10 TW
BLOQUEIOS TABELAS
BLOQUEIO DO MATERIAL/CENTRO
call function 'ENQUEUE_EMMARCE' exporting mode_marc = 'E' mandt = sy-mandt matnr = it_corte-matnr werks = p_werks exceptions foreign_lock = 1 system_failure = 2 others = 3.
BLOQUEIO MATERIAL & MKAL & CENTRO (VERSÃO DE PRODUÇÃO)
call function 'ENQUEUE_EMATVER' exporting mode_mkal = 'E' mandt = sy-mandt matnr = p_artigo werks = p_werks verid = p_verid exceptions foreign_lock = 1 system_failure = 2 others = 3.
BLOQUEIO MATERIAL/CENTRO PARA TABELA MBEW (Tabela avaliação material)
call function 'ENQUEUE_EMMBEWS' exporting mode_mbew = 'S' mandt = sy-mandt matnr = p_artigo bwkey = p_werks exceptions foreign_lock = 1 system_failure = 2 others = 3.
BLOQUEIA CENTRO DE TRABALHO
call function 'ENQUEUE_ECARPL' exporting mandt = sy-mandt arbpl = p_arbpl werks = p_werks exceptions foreign_lock = 1 system_failure = 2 others = 3.
BLOQUEIA ORDEM DE PRODUÇÃO
* Bloqueia a OP
call function 'CO_RU_ORDER_LOCK' exporting
aufnr_imp = vc_op. * Desbloqueia a OP
call function 'CO_RU_ORDER_DEQUEUE' exporting
aufnr_imp = vc_op.
BLOQUEIO DO MATERIAL
call function 'ENQUEUE_EMMARCE' exporting mode_marc = 'E' mandt = sy-mandt matnr = p_matnr werks = p_werks exceptions foreign_lock = 1 system_failure = 2 others = 3. do 10 times.
call function 'DEQUEUE_EMMCHA' exporting mode_mcha = 'E' matnr = p_matnr mandt = sy-mandt werks = p_werks charg = p_charg exceptions foreign_lock = 1 system_failure = 2 others = 99. enddo. st_seqg3-gname = 'MCHA'. st_seqg3-garg = sy-mandt. st_seqg3-garg+03(18) = p_matnr. st_seqg3-garg+21(04) = p_werks. st_seqg3-garg+25(10) = p_charg.
data: vi_number like sy-tabix.
data: it_enq like seqg3 occurs 0 with header line. vi_number = 1.
* Esperar liberação do bloqueio while vi_number > 0.
call function 'ENQUEUE_READ' exporting gclient = sy-mandt gname = p_seqg3-gname garg = p_seqg3-garg guname = sy-uname importing number = vi_number tables enq = it_enq exceptions communication_failure = 1 system_failure = 2 others = 3. endwhile.
BLOQUEIO DA ORDEM PLANEJADA
call function 'DEQUEUE_EMPLAFE' exporting
mode_vbak = 'E' mandt = sy-mandt vbeln = it_plaf_excl-plnum.
BLOQUEIA TABELA
call function 'ENQUEUE_E_TABLEE' exporting
mode_rstable = 'E' tabname = v_table exceptions
system_failure = 2 others = 3.
BLOQUEIO DA ORDEM
call function 'ENQUEUE_EVVBAKE' exporting mode_vbak = 'E' mandt = sy-mandt vbeln = it_vbak-vbeln exceptions foreign_lock = 1 system_failure = 2 others = 3.
BLOQUEIO DO
call function 'ENQUEUE_EMMBEWE' exporting matnr = it_key-matnr bwkey = p_werks bwtar = ' ' exceptions foreign_lock = 01 system_failure = 02 endloop.
PROCESSAMENTO PARALELO
PROCESSAMENTO PARALELO
form parallel_initialize. clear: wp_total, wp_available, wp_parallel. check p_parall = c_on. call function 'SPBT_INITIALIZE' exporting group_name = wp_group importing max_pbt_wps = wp_total free_pbt_wps = wp_available exceptions invalid_group_name = 1 internal_error = 2 pbt_env_already_initialized = 3 currently_no_resources_avail = 4 no_pbt_resources_found = 5 cant_init_different_pbt_groups = 6 others = 7. if sy-subrc eq 0. wp_parallel = c_on. endif.* GROUP_NAME - Name of group to check
* MAX_PBT_WPS - Total number of dialog work processes available in * group
* FREE_PBT_WPS - Number of work processes available in group for * parallel processing at this moment
* INVALID_GROUP_NAME
* Incorrect group name; RFC group not defined. See transaction RZ12 * INTERNAL_ERROR
* R/3 System error; see the system log (transaction SM21) for diagnostic * info
* PBT_ENV_ALREADY_INITIALIZED
* Function module may be called only once; is called automatically by * R/3 if you do not call before starting parallel processing
* CURRENTLY_NO_RESOURCES_AVAIL
* No dialog work processes in the group are available; they are busy or * server load is too high
* NO_PBT_RESOURCES_FOUND
* No servers in the group met the criteria of > two work processes * defined.
* CANT_INIT_DIFFERENT_PBT_GROUPS
* You have already initialized one group and have now tried initialize a * different group clear: wp_snd_jobs, wp_rcv_jobs, wp_taskname. refresh it_pack_caufv. if wp_parallel = c_off. call function 'Z_PPF009' exporting pi_parallel = wp_parallel tables t_caufv = t_caufv t_jest = it_jest. else.
* Divide the records into work packets wp_jobs = wp_available / 2.
wp_packs = vn_lines / wp_jobs. if wp_packs = 0. wp_packs = vn_lines. wp_jobs = 1. endif. it_save[] = t_caufv[]. clear t_caufv. refresh t_caufv. vi_ini = 1. vi_fim = wp_packs. do. clear it_pack. refresh it_pack.
append lines of it_save from vi_ini to vi_fim to it_pack. call function 'Z_PPF009' starting new task wp_taskname destination in group wp_group
performing return_zppf009 on end of task exporting pi_parallel = wp_parallel tables t_caufv = it_pack t_jest = it_jest. if sy-subrc eq 0. wp_snd_jobs = wp_snd_jobs + 1. wp_taskname = wp_taskname + 1. endif. wp_jobs = wp_jobs - 1. if wp_jobs <= 0. exit. endif. vi_ini = vi_fim + 1. add wp_packs to vi_fim. if vi_fim > vn_lines. vi_fim = vn_lines. endif.
if wp_jobs = 1 and vi_fim < vn_lines. vi_fim = vn_lines.
endif. enddo.
wait until wp_rcv_jobs >= wp_snd_jobs. append lines of it_pack_caufv to t_caufv. refresh it_pack_caufv.
describe table t_caufv lines sy-tmaxl. if sy-tmaxl <> vn_lines.
message s575(ck). stop.
endif. endif.
sort t_caufv by aufnr.
delete t_caufv where ente = c_on. if not t_caufv[] is initial.
select aufnr posnr wemng
appending table it_afpo from afpo
for all entries in t_caufv where aufnr = t_caufv-aufnr. sort it_afpo by aufnr
posnr. endif.
CONSISTENCIA CGC/CFP
function field_exit_stcd1.
* Tabela interna para uso em Fornecedores data: begin of it_lfa1 occurs 0,
lifnr like lfa1-lifnr, stcd1 like lfa1-stcd1, name1 like lfa1-name1. data: end of it_lfa1.
* Tabela interna para uso em Clientes data: begin of it_kna1 occurs 0, kunnr like kna1-kunnr, stcd1 like kna1-stcd1, name1 like kna1-name1. data: end of it_kna1.
data: vc_lifnr like lfa1-lifnr. data: vc_kunnr like kna1-kunnr. data: vc_ktokd like kna1-ktokd. output = input.
if input is initial. exit.
endif.
* Procedimentos para Fornecedores if sy-tcode = 'XK01' or sy-tcode = 'XK02' or sy-tcode = 'XK03' or sy-tcode = 'MK01' or sy-tcode = 'MK02' or sy-tcode = 'MK03' or sy-tcode = 'FK01' or sy-tcode = 'FK02' or sy-tcode = 'FK03' .
get parameter id 'LIF' field vc_lifnr. select lifnr
stcd1 name1
into table it_lfa1 from lfa1
where stcd1 = input. if sy-subrc ne 0.
exit. else.
loop at it_lfa1.
message e398(00) with text-001 it_lfa1-lifnr it_lfa1-name1. endloop.
endif. endif.
* Procedimentos para Clientes if sy-tcode = 'VD01' or sy-tcode = 'VD02' or sy-tcode = 'VD03' or sy-tcode = 'XD01' or sy-tcode = 'XD02' or sy-tcode = 'XD03' or sy-tcode = 'V-09' or sy-tcode = 'V-03' or sy-tcode = 'FD01' or sy-tcode = 'FD02' or sy-tcode = 'FD03'.
get parameter id 'KUN' field vc_kunnr. select single ktokd
into vc_ktokd from kna1
where kunnr = vc_kunnr.
if sy-subrc = 0 and vc_ktokd = 'RECE'. exit.
endif. select kunnr stcd1 name1
into table it_kna1 from kna1
where stcd1 = input. if sy-subrc ne 0.
exit. else.
delete it_kna1 where kunnr = vc_kunnr. loop at it_kna1.
message e398(00) with text-002 it_kna1-kunnr it_kna1-name1. endloop. endif. endif. endfunction.
NOTA FISCAL
OBTEM DADOS DA NOTA FISCAL
CALL FUNCTION 'J_1B_NF_DOCUMENT_READ' EXPORTING
doc_number = p_docnum (informar num NF) IMPORTING doc_header = wk_header TABLES doc_partner = wk_partner doc_item = wk_item doc_item_tax = wk_item_tax doc_header_msg = wk_header_msg1 doc_refer_msg = wk_refer_msg EXCEPTIONS document_not_found = 1 docum_lock = 2 OTHERS = 3.
OBTEM DADOS DA FATURA
CALL FUNCTION 'J_1B_NF_VALUE_DETERMINATION' EXPORTING
IMPORTING ext_header = wk_header_add TABLES nf_item = wk_item nf_item_tax = wk_item_tax ext_item = wk_item_add.
OBTEM DADOS DO DESTINATÁRIO NF
CALL FUNCTION 'READ_TEXT_INLINE' EXPORTING id = '0004' inline_count = 15 language = 'P' name = xthead-tdname object = 'VBBK' IMPORTING header = thead TABLES inlines = tinlinetab lines = tlinetab EXCEPTIONS id = 1 language = 2
OBTEM PARCEIRO DA NOTA FISCAL
CALL FUNCTION 'J_1B_NF_PARTNER_READ' EXPORTING partner_type = destination-partner_type partner_id = destination-partner_id partner_function = destination-partner_function doc_number = wk_header-docnum IMPORTING parnad = j_1binnad EXCEPTIONS partner_not_found = 1 partner_type_not_found = 2 OTHERS = 3.
CRIA TEXTO DESCRITIVO
CALL FUNCTION 'CREATE_TEXT' EXPORTING fid = 'BEST' flanguage = sy-langu fname = vc_matnrt fobject = 'MATERIAL' * SAVE_DIRECT = 'X' fformat = '=' TABLES flines = it_linha EXCEPTIONS no_init = 1 no_save = 2 OTHERS = 3.
CONVERTE CAMPO FLOAT EM CHAR
call function 'FLTP_CHAR_CONVERSION' exporting decim = 15 expon = 0 input = v_flt * IVALU = ' ' * MASKN = ' ' importing flstr = vc_char exceptions others = 1.