1) Create a new smart Form using
transaction SMARTFORMS.


2) Create an Action Profile in PPF
Output Management of SAP TRANSPORTATION
Transaction Code:
SCPPFADM
Select the
Application and click Define Action Profile and Actions


Action Profile ZTM_AP_PICK_LIST

Action Definition ZTM_AD_PICK_LIST


3) Maintain Conditions for the Action
Profile
3.1) Assign Smartforms name



3.2) Start Condition (Optional)
The purpose of this
condition is to filter from printing only for Yellow (unprocessed) Item. Not
Red (error) nor Green (already printed).

Create Start
Condition: ZTMFV_EVAL_START_CONDITION
Copied from /BOFU/EVAL_START_CONDITION

Implementation
Name: ZTMBD_PPF_STD_EV_STA (copied of /BOFU/PPF_STD_EV_STA)
Implementation Class: ZCL_IM_TMBD_PPF_STD_EV_STA
(copied form /BOFU/CL_IM_PPF_STD_EV_STA )
Properties:

Interface:

Method: IF_EX_EVAL_STARTCOND_PPF~EVALUATE_START_CONDITION
|
METHOD if_ex_eval_startcond_ppf~evaluate_start_condition.
* Standard Implementation of BADI method Evaluate Start Condition
DATA: lo_facade TYPE REF TO ztmcl_pls_ppf_badi_facade. "/bofu/cl_ppf_badi_facade.
* lo_facade ?= /bofu/cl_ppf_badi_facade=>get_instance( ).
lo_facade ?= ztmcl_pls_ppf_badi_facade=>get_instance( ).
CALL METHOD lo_facade->if_ex_eval_startcond_ppf~evaluate_start_condition
EXPORTING
flt_val = flt_val
io_context = io_context
ip_protocol = ip_protocol
ip_ttype = ip_ttype
ii_container = ii_container
IMPORTING
ep_rc = ep_rc.
*H4DK902481 DIVAN 20260525 -- INS BEG
*Custom codes/method
IF ep_rc = 0.
CALL METHOD lo_facade->evaluate_start_condition
EXPORTING
io_context = io_context
IMPORTING
ep_rc = ep_rc.
ENDIF.
*H4DK902481 DIVAN 20260525 -- INS END
ENDMETHOD.
|
Create Class: ZTMCL_PLS_PPF_BADI_FACADE
(copied from /BOFU/CL_PPF_BADI_FACADE)
Add new Method: EVALUATE_START_CONDITION
You may copy
parameters from Method IF_EX_EVAL_STARTCOND_PPF~EVALUATE_START_CONDITION

|
METHOD evaluate_start_condition.
DATA: lo_message TYPE REF TO /bobf/if_frw_message,
lo_container TYPE REF TO /bofu/cl_ppf_container,
lv_db_key TYPE /bobf/conf_key,
lv_trigger_guid TYPE guid_32,
lv_attr TYPE ppfdsortfd,
lv_msg TYPE string,
ls_msg TYPE symsg.
CONSTANTS: lc_not_processed TYPE ppfttrigg-status VALUE '0'.
* ep_rc = 1.
lo_container ?= io_context->appl.
"Via this container, determine the Node Instance, Node key, BO key ...
CALL METHOD lo_container->get_db_key
RECEIVING
result = lv_db_key.
"Get Execution status
SELECT SINGLE db_key, execution
FROM /scmtms/d_torrot
INTO @DATA(ls_torrot)
WHERE db_key = @lv_db_key.
CHECK sy-subrc IS INITIAL.
"Get output device from paramater table
SELECT SINGLE h~zzmodul, h~zzparamid,
d~zzparam1, d~zzdata1, d~zzderval1
FROM zcat_usrparamh AS h
INNER JOIN zcat_usrparamd AS d
ON h~zzmodul = d~zzmodul
AND h~zzparamid = d~zzparamid
INTO @DATA(ls_param)
WHERE h~zzmodul = 'TM'
AND h~zzparamid = 'PICKLISTSUM_START_COND'
AND d~zzparam1 = 'EXECUTION'
AND d~zzactiv = @abap_true.
CHECK sy-subrc IS INITIAL.
IF ls_param-zzdata1 = ls_torrot-execution AND
ls_param-zzderval1 = abap_true.
"Get Trigger GUID
GET PARAMETER ID 'TRIGGERGUID' FIELD lv_trigger_guid.
"Check for unprocessed ID
SELECT SINGLE *
FROM ppfttrigg
INTO @DATA(ls_ppfttrigg)
WHERE os_guid = @lv_trigger_guid
AND applkey = @lv_db_key
AND status = @lc_not_processed. "0 = Yellow
IF sy-subrc IS INITIAL.
ep_rc = 0.
ELSE.
ep_rc = 1.
ENDIF.
ELSE.
ep_rc = 1.
"Execution status must be set "In Execution"
ls_msg = VALUE #( msgty = 'E'
msgid = '00'
msgno = '398'
msgv1 = TEXT-001 ).
MESSAGE e398(00)
WITH TEXT-001 '' '' ''
INTO lv_msg.
IF lo_message IS NOT BOUND.
lo_message = /bobf/cl_frw_factory=>get_message( ).
ENDIF.
CALL METHOD lo_message->add_message
EXPORTING
is_msg = ls_msg.
CALL METHOD add_messages_to_app_log
EXPORTING
io_message = lo_message
iv_appl_log_handle = ip_protocol.
ENDIF.
ENDMETHOD.
|
4) Maintain Output Management Adapter
Settings
TCode SPRO > SAP
Customizing Implementation Guide > Cross-Application Components > Processes
and Tools for Enterprise Applications > Reusable Objects and Functions for
BOPF Environment > PPF Adapter for Output Management > Maintain Output
Management Adapter Settings



5) Implement below Method in agent
Class ZWMCL_PPF_SERV_FOR_TOR
Copied from Class /SCMTMS/CL_PPF_SERV_FOR_TOR
And must have a
Superclass
|
method /BOFU/IF_PPF_SERV_FOR_BO~PERSONALIZE_DOC_BCS_VAR_REPL.
*{ INSERT H4DK902404 1
DATA: lv_fm_fname TYPE rs38l_fnam,
lv_rootkey TYPE /bobf/conf_key,
lv_tor_id TYPE /scmtms/d_torrot-tor_id,
lr_tortyp TYPE RANGE OF /scmtms/d_torrot-tor_type.
.
SELECT * FROM zcat_usrparamd
INTO TABLE @DATA(lt_tortyp)
WHERE zzmodul = 'TM'
AND zzparamid = 'PICKLISTSUM_TOR_TYPE'
AND zzparam1 = 'TOR_TYPE'.
IF sy-subrc IS INITIAL.
LOOP AT lt_tortyp INTO DATA(ls_tortyp).
lr_tortyp = VALUE #( BASE lr_tortyp
( sign = ls_tortyp-zzsign
option = ls_tortyp-zzoption
low = ls_tortyp-zzderval1
high = ls_tortyp-zzderval2
)
).
ENDLOOP.
ENDIF.
CHECK lr_tortyp[] IS NOT INITIAL.
TRY.
CALL METHOD io_container->get_bo_root_key
RECEIVING
result = lv_rootkey.
SELECT SINGLE *
FROM /scmtms/d_torrot
INTO @DATA(ls_torrot)
WHERE db_key = @lv_rootkey.
IF ls_torrot-tor_type IN lr_tortyp.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = ip_smart_form
variant = space
direct_call = space
IMPORTING
fm_name = lv_fm_fname
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
"Implement suitable error handling here
APPEND INITIAL LINE TO et_error_tab ASSIGNING FIELD-SYMBOL(<lfs_err>).
<lfs_err> = VALUE #( docnumber = lv_rootkey
form = ip_smart_form
errnumber = 1
msgid = sy-msgid
msgty = sy-msgty
msgno = sy-msgno
msgv1 = sy-msgv1
msgv2 = sy-msgv2
msgv3 = sy-msgv3
msgv4 = sy-msgv4 ).
ELSE.
IF lv_fm_fname IS NOT INITIAL.
CALL FUNCTION lv_fm_fname
EXPORTING
control_parameters = is_control_parameters
mail_appl_obj = is_mail_appl_obj
mail_recipient = is_mail_recipient
mail_sender = is_mail_sender
output_options = is_output_options
is_torrot = ls_torrot
IMPORTING
document_output_info = es_document_output_info
job_output_info = es_job_output_info
job_output_options = es_job_output_options
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
"Implement suitable error handling here
APPEND INITIAL LINE TO et_error_tab ASSIGNING <lfs_err>.
<lfs_err> = VALUE #( docnumber = lv_rootkey
form = ip_smart_form
errnumber = 1
msgid = sy-msgid
msgty = sy-msgty
msgno = sy-msgno
msgv1 = sy-msgv1
msgv2 = sy-msgv2
msgv3 = sy-msgv3
msgv4 = sy-msgv4 ).
ENDIF.
ENDIF. "lv_fm_fname IS NOT INITIAL.
ENDIF. "CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
ENDIF. "SELECT SINGLE * FROM /scmtms/d_torrot
CATCH cx_os_object_not_found.
ENDTRY. *} INSERT
endmethod.
|
6) Maintain the output Profile in TOR
TCode SPRO > SAP
Customizing Implementation Guide > Transportation Management > Freight
Order Management > Freight Order > Define Freight Order Types



7) Define initial Output Device in
User ID (TCode SU01)


If it's not
maintained, it'll get this error message:

If maintained, can
continue printing/preview printing

Preview
8) Testing: Create a new Freight
order, it will show the SmartForms in spool.
Once successfully
printed (green light),
The spool created

No comments :
Post a Comment