********************************************************************************
* INFORMACIÓN GENERAL - GENERAL INFORMATION
********************************************************************************
*^ Autor - Author : José Manrique Valderrama
*^ Objetivo - Objetive : Inline Declaratinos
*^ Website : abapejemplos.blogspot.com
********************************************************************************
REPORT Zjm_demo_inline.
START-OF-SELECTION.
" Declarar tabla en un SELECT
SELECT * UP TO 1 ROWS
FROM mara
INTO TABLE @DATA(gdt_mara).
" Declarar Work Area
READ TABLE gdt_mara INTO DATA(gwa_mara) INDEX 1.
" Declarar Field Symbol
READ TABLE gdt_mara ASSIGNING FIELD-SYMBOL( |
martes, 11 de junio de 2019
Declaraciones Inline en ABAP 7.40 (Inline declarations)
Etiquetas:
7.40,
7.50,
ABAP,
DECLARACION,
DECLARATION,
EJEMPLO,
EXAMPLE,
HANA,
HOW TO,
INLINE,
OO,
PROGRAMACIÓN,
SAMPLE,
SAP,
UTILES
sábado, 4 de noviembre de 2017
BAPI_SHIPMENT_CREATE - VT01N
********************************************************************************
* INFORMACIÓN GENERAL - GENERAL INFORMATION
********************************************************************************
*^ Autor - Author : José Manrique Valderrama
*^ Objetivo - Objetive : Creación de Documento de transporte (Shipment) - VT01N
*^ Website : abapejemplos.blogspot.com
********************************************************************************
REPORT zjm_demo_shipment.
PARAMETERS: p_tplst TYPE vttk-tplst OBLIGATORY,
p_shtyp TYPE vttk-shtyp OBLIGATORY,
p_vbeln TYPE lips-vbeln.
DATA: gdt_item TYPE STANDARD TABLE OF bapishipmentitem,
gdt_dlin TYPE STANDARD TABLE OF bapishipmentheaderdeadline,
gdt_ret2 TYPE bapiret2_tab.
DATA: gwa_header TYPE bapishipmentheader.
FIELD-SYMBOLS: <fs_item> TYPE bapishipmentitem,
<fs_dlin> TYPE bapishipmentheaderdeadline,
<fs_ret2> TYPE bapiret2.
DATA: gv_tknum TYPE vttk-tknum.
START-OF-SELECTION.
REFRESH: gdt_item,
gdt_dlin,
gdt_ret2.
CLEAR: gwa_header,
gv_tknum.
"Cabecera del Documento de transporte
gwa_header-shipment_type = p_shtyp.
gwa_header-trans_plan_pt = p_tplst.
"Se inicia en status Planificado
"Se puede iniciar en otro status, se deben marcar todos los status previos
gwa_header-status_plan = abap_true.
"Se completa la fecha y hora de cada status
APPEND INITIAL LINE TO gdt_dlin ASSIGNING <fs_dlin>.
<fs_dlin>-time_type = 'HDRSTPLDT'.
<fs_dlin>-time_stamp_utc = sy-datum && sy-uzeit.
<fs_dlin>-time_zone = 'UTC'.
*SAP-Note 531207
*TIME_TYPE = HDRSTPLDT --> Date/time of end of planning
*TIME_TYPE = HDRSTCIPDT --> PLANNED date/time of check-in
*TIME_TYPE = HDRSTCIADT --> ACTUAL date/time of check-in
*TIME_TYPE = HDRSTLSPDT --> PLANNED date/time of loading start
*TIME_TYPE = HDRSTLSADT --> ACTUAL date/time of loading start
*TIME_TYPE = HDRSTLEPDT --> PLANNED date/time of loading end
*TIME_TYPE = HDRSTLEADT --> ACTUAL date/time of loading end
*TIME_TYPE = HDRSTCPDT --> PLANNED date/time of shipment completion
*TIME_TYPE = HDRSTCADT --> ACTUAL date/time of shipment completion
*TIME_TYPE = HDRSTSSPDT --> PLANNED date/time of shipment start
*TIME_TYPE = HDRSTSSADT --> ACTUAL date/time of shipment start
*TIME_TYPE = HDRSTSEPDT --> PLANNED date/time of shipment end
*TIME_TYPE = HDRSTSEADT --> ACTUAL date/time of shipment end
"Se pueden asignar las entregas, no es obligatorio.
IF p_vbeln IS NOT INITIAL.
APPEND INITIAL LINE TO gdt_item ASSIGNING |
Etiquetas:
ABAP,
BAPI,
BAPI_SHIPMENT_CREATE,
EJEMPLO,
EXAMPLE,
FUNCION,
FUNCTIONS,
PROGRAMACIÓN,
SAMPLE,
SAP,
SHIPMENT,
SIMPLE,
TRANSPORTE; LE-TRA,
VT01N
sábado, 23 de abril de 2016
ALV Factory - Ordenamiento, Totales y Subtotales
******************************************************************************** * INFORMACIÓN GENERAL - GENERAL INFORMATION ******************************************************************************** *^ Autor - Author : José Manrique Valderrama *^ Objetivo - Objetive : TEST - ALV FACTORY *^ Website : abapejemplos.blogspot.com ******************************************************************************** REPORT zjm_demo_alv_factory. DATA: gtd_sflight TYPE STANDARD TABLE OF sflight. DATA: gwa_sflight TYPE sflight. DATA: go_alv TYPE REF TO cl_salv_table, go_sorts TYPE REF TO cl_salv_sorts, go_aggrs TYPE REF TO cl_salv_aggregations. * Párametros de selección PARAMETERS: p_carrid TYPE sflight-carrid OBLIGATORY. SELECT-OPTIONS: s_connid FOR gwa_sflight-connid, s_fldate FOR gwa_sflight-fldate. START-OF-SELECTION. SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE gtd_sflight WHERE carrid EQ p_carrid AND connid IN s_connid AND fldate IN s_fldate. IF sy-subrc NE 0. "No se encontraron datos para esta ejecución MESSAGE s425(fr) DISPLAY LIKE 'E'. RETURN. ENDIF. TRY. cl_salv_table=>factory( IMPORTING r_salv_table = go_alv CHANGING t_table = gtd_sflight ). CATCH cx_salv_msg. "Se ha producido un error en ALV MESSAGE s899(salv_exception) DISPLAY LIKE 'E'. RETURN. ENDTRY. go_sorts = go_alv->get_sorts( ). TRY. go_sorts->add_sort( columnname = 'FLDATE' "Columna a ordenar position = 1 "1er criterio de ordenamiento sequence = if_salv_c_sort=>sort_up "Orden Ascendente subtotal = abap_true ). "Se utiliza para Subtotales CATCH cx_salv_data_error cx_salv_not_found cx_salv_existing . "Se ha producido un error en ALV MESSAGE s899(salv_exception) DISPLAY LIKE 'E'. RETURN. ENDTRY. go_aggrs = go_alv->get_aggregations( ). TRY. go_aggrs->add_aggregation( columnname = 'PAYMENTSUM' "Columna aggregation = if_salv_c_aggregation=>total ). "Totalizar(suma) CATCH cx_salv_data_error cx_salv_not_found cx_salv_existing . "Se ha producido un error en ALV MESSAGE s899(salv_exception) DISPLAY LIKE 'E'. RETURN. ENDTRY. * Se activan todas las funciones(botones) estándar del ALV go_alv->get_functions( )->set_all( abap_true ). go_alv->display( ). |
Etiquetas:
ABAP,
ALV,
CL_SALV_TABLE,
DEVELOPMENT,
EJEMPLO,
EXAMPLE,
FACTORY,
HOW TO,
OBJETOS,
OO,
ORDENAMIENTO,
ORDENAR,
PROGRAMACIÓN,
ReportesALV,
SAP,
SIMPLE,
SORT; AGREGACIÓN,
SUBTOTALES,
SUMA,
TOTALES
domingo, 20 de marzo de 2016
Envío de correo con PDF - OO
******************************************************************************** * INFORMACIÓN GENERAL - GENERAL INFORMATION ******************************************************************************** *^ Autor - Author : José Manrique Valderrama *^ Objetivo - Objetive : Envío de correos OO con PDF *^ Website : abapejemplos.blogspot.com ******************************************************************************** REPORT zjm_demo_email. DATA: gdt_text TYPE soli_tab, gdt_lines TYPE tline_t, gdt_pdf TYPE solix_tab. DATA: gwa_parameters TYPE ssfctrlop, gwa_outoptions TYPE ssfcompop, gwa_outinfo TYPE ssfcrescl. DATA: go_bcs TYPE REF TO cl_bcs, go_document TYPE REF TO cl_document_bcs, go_address TYPE REF TO cl_cam_address_bcs. DATA: gs_formname TYPE tdsfname, gs_subject TYPE so_obj_des, gs_result TYPE os_boolean, gs_funcname TYPE rs38l_fnam, gs_file TYPE xstring, gi_size TYPE i, gs_archivo TYPE so_obj_des. PARAMETERS: p_email TYPE ad_smtpadr. START-OF-SELECTION. gs_formname = 'ZJM_DEMO_EMAIL'. "Se obtiene el nombre del Módulo de Funciones para el SMARTFORM CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = gs_formname IMPORTING fm_name = gs_funcname EXCEPTIONS no_form = 1 no_function_module = 2 OTHERS = 3. IF sy-subrc NE 0. "Error en el nombre del SMARTFORM, revisar RETURN. ENDIF. "Se completan datos para la ejecución del SMARTFORM CLEAR gwa_parameters. "Indicar que se va a recibir el OTF gwa_parameters-getotf = abap_true. "No mostar pantalla de diálogo de impresión gwa_parameters-no_dialog = abap_true. "Sin previsualización gwa_parameters-preview = abap_false. "Se completan datos específicos de la impresión CLEAR gwa_outoptions. gwa_outoptions-tddest = 'LP01'. "Impresora para simulación CALL FUNCTION gs_funcname EXPORTING control_parameters = gwa_parameters output_options = gwa_outoptions user_settings = abap_false "Activar si se usa config. del usuario IMPORTING job_output_info = gwa_outinfo EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 OTHERS = 5. IF sy-subrc NE 0. "Error al ejecutar el SMARTFORM, revisar RETURN. ENDIF. "Se convierte el OTF obtenido a formato PDF, en GS_FILE CALL FUNCTION 'CONVERT_OTF' EXPORTING format = 'PDF' IMPORTING bin_filesize = gi_size bin_file = gs_file TABLES otf = gwa_outinfo-otfdata lines = gdt_lines EXCEPTIONS err_max_linewidth = 1 err_format = 2 err_conv_not_possible = 3 err_bad_otf = 4 OTHERS = 5. IF sy-subrc NE 0. "Error al convertir OTF a PDF RETURN. ENDIF. "La cadena binaria obtenida se convierte en tabla CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING buffer = gs_file TABLES binary_tab = gdt_pdf. "Esta tabla se envía por correo TRY. go_bcs = cl_bcs=>create_persistent( ). CATCH cx_send_req_bcs. "Error al crear objeto de correo RETURN. ENDTRY. APPEND 'Se adjunta PDF, descargar archivo' TO gdt_text. gs_subject = 'Asunto del correo con PDF'. TRY. go_document = cl_document_bcs=>create_document( i_type = 'RAW' i_text = gdt_text i_subject = gs_subject ). CATCH cx_document_bcs. "Error al crear contenido del correo RETURN. ENDTRY. gs_archivo = 'ARCHIVO_PDF'. "Nombre del archivo sin extensión "Se adjunta el PDF TRY. go_document->add_attachment( EXPORTING i_attachment_type = 'PDF' i_attachment_subject = gs_archivo i_att_content_hex = gdt_pdf ). CATCH cx_document_bcs. RETURN. ENDTRY. TRY. go_address = cl_cam_address_bcs=>create_internet_address( p_email ). CATCH cx_address_bcs. "Error al crear objeto de destinatario RETURN. ENDTRY. TRY. go_bcs->set_document( go_document ). CATCH cx_send_req_bcs. "Error al asignar el objeto de correo RETURN. ENDTRY. TRY. go_bcs->add_recipient( go_address ). CATCH cx_send_req_bcs. "Error al agregar destinatario a la lista RETURN. ENDTRY. TRY. go_bcs->set_send_immediately( abap_true ). CATCH cx_send_req_bcs. "Error al marcar el correo como envio inmediato RETURN. ENDTRY. TRY. "Enviar con error en pantalla gs_result = go_bcs->send( abap_true ). CATCH cx_send_req_bcs. "Error al setear el envío de correo RETURN. ENDTRY. IF gs_result EQ abap_true. "Se confirma el envío, es necesario. COMMIT WORK. ENDIF. |
Resultado del envío de correo:
PDF Adjunto:
Envío de correo OO con HTML
******************************************************************************** * INFORMACIÓN GENERAL - GENERAL INFORMATION ******************************************************************************** *^ Autor - Author : José Manrique Valderrama *^ Objetivo - Objetive : Envío de correos OO con HTML *^ Website : abapejemplos.blogspot.com ******************************************************************************** REPORT zjm_demo_email. DATA: gdt_html TYPE soli_tab. DATA: go_bcs TYPE REF TO cl_bcs, go_document TYPE REF TO cl_document_bcs, go_address TYPE REF TO cl_cam_address_bcs. DATA: gs_subject TYPE so_obj_des, gs_result TYPE os_boolean. PARAMETERS: p_email TYPE ad_smtpadr. START-OF-SELECTION. TRY. go_bcs = cl_bcs=>create_persistent( ). CATCH cx_send_req_bcs. "Error al crear objeto de correo RETURN. ENDTRY. APPEND '<HTML>' TO gdt_html. APPEND '<H1>Título 1</H1>' TO gdt_html. APPEND '<H2>Título 2</H2>' TO gdt_html. APPEND '<H3>Título 3</H3>' TO gdt_html. APPEND '<TABLE BORDER = "1">' TO gdt_html. APPEND '<TR>' TO gdt_html. APPEND '<TD><B>Campo 1</B></TD>' TO gdt_html. APPEND '<TD><B>Campo 2</B></TD>' TO gdt_html. APPEND '</TR>' TO gdt_html. APPEND '<TR>' TO gdt_html. APPEND '<TD>Valor 1</TD>' TO gdt_html. APPEND '<TD>Valor 2</TD>' TO gdt_html. APPEND '</TR>' TO gdt_html. APPEND '</TABLE>' TO gdt_html. APPEND '</HTML>' TO gdt_html. gs_subject = 'Asunto del correo HTML'. TRY. go_document = cl_document_bcs=>create_document( i_type = 'HTM' i_text = gdt_html i_subject = gs_subject ). CATCH cx_document_bcs. "Error al crear contenido del correo RETURN. ENDTRY. TRY. go_address = cl_cam_address_bcs=>create_internet_address( p_email ). CATCH cx_address_bcs. "Error al crear objeto de destinatario RETURN. ENDTRY. TRY. go_bcs->set_document( go_document ). CATCH cx_send_req_bcs. "Error al asignar el objeto de correo RETURN. ENDTRY. TRY. go_bcs->add_recipient( go_address ). CATCH cx_send_req_bcs. "Error al agregar destinatario a la lista RETURN. ENDTRY. TRY. go_bcs->set_send_immediately( abap_true ). CATCH cx_send_req_bcs. "Error al marcar el correo como envio inmediato RETURN. ENDTRY. TRY. "Enviar con error en pantalla gs_result = go_bcs->send( abap_true ). CATCH cx_send_req_bcs. "Error al setear el envío de correo RETURN. ENDTRY. IF gs_result EQ abap_true. "Se confirma el envío, es necesario. COMMIT WORK. ENDIF. |
Envío de correos
Lista de programas para enviar correos
- Envío de correo simple
- Envío de correo - Orientado a Objetos
- Envío de correo con HTML - OO
- Envío de correo con PDF adjunto - OO
Envío de correos OO
******************************************************************************** * INFORMACIÓN GENERAL - GENERAL INFORMATION ******************************************************************************** *^ Autor - Author : José Manrique Valderrama *^ Objetivo - Objetive : Envío de correos OO *^ Website : abapejemplos.blogspot.com ******************************************************************************** REPORT zjm_demo_email. DATA: gdt_text TYPE soli_tab. DATA: go_bcs TYPE REF TO cl_bcs, go_document TYPE REF TO cl_document_bcs, go_address TYPE REF TO cl_cam_address_bcs. DATA: gs_subject TYPE so_obj_des, gs_result TYPE os_boolean. PARAMETERS: p_email TYPE ad_smtpadr. START-OF-SELECTION. TRY. go_bcs = cl_bcs=>create_persistent( ). CATCH cx_send_req_bcs. "Error al crear objeto de correo RETURN. ENDTRY. APPEND 'Ese es el cuerpo del correo' TO gdt_text. gs_subject = 'Asunto del correo'. TRY. go_document = cl_document_bcs=>create_document( i_type = 'RAW' i_text = gdt_text i_subject = gs_subject ). CATCH cx_document_bcs. "Error al crear contenido del correo RETURN. ENDTRY. TRY. go_address = cl_cam_address_bcs=>create_internet_address( p_email ). CATCH cx_address_bcs. "Error al crear objeto de destinatario RETURN. ENDTRY. TRY. go_bcs->set_document( go_document ). CATCH cx_send_req_bcs. "Error al asignar el objeto de correo RETURN. ENDTRY. TRY. go_bcs->add_recipient( go_address ). CATCH cx_send_req_bcs. "Error al agregar destinatario a la lista RETURN. ENDTRY. TRY. go_bcs->set_send_immediately( abap_true ). CATCH cx_send_req_bcs. "Error al marcar el correo como envio inmediato RETURN. ENDTRY. TRY. "Enviar con error en pantalla gs_result = go_bcs->send( abap_true ). CATCH cx_send_req_bcs. "Error al setear el envío de correo RETURN. ENDTRY. IF gs_result EQ abap_true. "Se confirma el envío, es necesario. COMMIT WORK. ENDIF. |
Suscribirse a:
Entradas (Atom)