Jun 17, 2026

Upload Internal Table to AL11 in Sap Abap

To upload internal table data to the SAP Application Server (Transaction AL11), you must use standard ABAP Dataset statements: OPEN DATASET, TRANSFER, and CLOSE DATASET. 

Below is a direct answer and complete guide on how to implement this programmatically. 
1. Simple Text Mode Upload
Use TEXT MODE if you want to upload data as a standard text file or CSV. 
abap
DATA: lv_filepath TYPE string VALUE '/usr/sap/interfaces/test_file.txt',
      ls_data     TYPE ty_your_structure. " Replace with your structure type

" Step 1: Open the application server file path
OPEN DATASET lv_filepath FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc = 0.
  " Step 2: Loop through the internal table and transfer records
  LOOP AT lt_internal_table INTO ls_data.
    TRANSFER ls_data TO lv_filepath.
  --ENDLOOP.

  " Step 3: Close the dataset (Mandatory)
  CLOSE DATASET lv_filepath.
  MESSAGE 'File uploaded successfully to AL11' TYPE 'S'.
ELSE.
  MESSAGE 'Error opening file path on AL11' TYPE 'E'.
ENDIF.
2. Comma-Separated Values (CSV) Upload 
If you want to view the fields properly structured in a spreadsheet layout later, convert the table to a string/CSV format using SAP_CONVERT_TO_CSV_FORMAT before sending it to the server.
abap
DATA: lv_filepath   TYPE string VALUE '/tmp/sales_data.csv',
      lt_csv_format TYPE truxs_t_text_data, " Standard table type for text
      lv_csv_line   TYPE string.

" Step 1: Convert internal table to CSV structure
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
  EXPORTING
    i_field_seperator    = ','
  TABLES
    i_tab_sap_data       = lt_internal_table
  CHANGING
    i_tab_converted_data = lt_csv_format
  EXCEPTIONS
    conversion_failed    = 1
    OTHERS               = 2.

IF sy-subrc = 0.
  " Step 2: Write to Application Server
  OPEN DATASET lv_filepath FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
  
  IF sy-subrc = 0.
    LOOP AT lt_csv_format INTO lv_csv_line.
      TRANSFER lv_csv_line TO lv_filepath.
    ENDLOOP.
    CLOSE DATASET lv_filepath.
  ENDIF.
ENDIF.
3. Binary Mode Upload (For Excel / Zip / Images)
Use BINARY MODE if your data is an XSTRING or raw binary data stream (e.g., generating an actual .xlsx file using cl_salv_bs_lex). 
abap
DATA: lv_filepath TYPE string VALUE '/usr/sap/interfaces/report.xlsx',
      lv_xstring  TYPE xstring. " Contains your binary file data

OPEN DATASET lv_filepath FOR OUTPUT IN BINARY MODE.
IF sy-subrc = 0.
  TRANSFER lv_xstring TO lv_filepath.
  CLOSE DATASET lv_filepath.
ENDIF.
Key Syntax Reminders
  • FOR OUTPUT: Opens a file for writing. If the file already exists, this completely overwrites its contents.
  • FOR APPENDING: Opens a file and places the cursor at the end of the existing text. Use this if you want to append new rows without losing old logs.
  • ENCODING DEFAULT: Mandatory constraint for text mode file handling in modern Unicode SAP environments. 
If you would like, tell me:
  • What file type do you want to create in AL11 (TXT, CSV, XLSX)?
  • Are you handling large datasets that require specific block sizing?
I can provide the exact target layout adjustments or helper class transformations you need!

Jun 3, 2026

SmartForms in SAP TM using PPF (Freight Order Printing Configurations)

 

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
    
DATAlo_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.

    
DATAlo_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.

    
CONSTANTSlc_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_keyexecution
      
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
~zzparam1d~zzdata1d~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