ABAP SFP function

*&---------------------------------------------------------------------*
*& Form PROCESS_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TB_INDEX text
*----------------------------------------------------------------------*

FORM PROCESS_COMMAND USING P_TB_INDEX.

DATA: IE_OUTPUTPARAM TYPE SFPOUTPUTPARAMS.
I_NAME TYPE FPNAME,
I_FUNCNAME TYPE FUNCNAME,

IM_TEXT TYPE STRING,
LOGFILEOBJ TYPE REF TO CL_LSO_LOGFILE.
SZ_OBJID(50),
ICOUNT TYPE SY-INDEX,
AR_CONNECTIONS TYPE TOAV0 OCCURS 1 WITH HEADER LINE,
AR_DOCCLASS TYPE TOADD-DOC_TYPE,
BINDATALIKE TBL1024 OCCURS 0 WITH HEADER LINE,
SZ_XSTRING TYPE XSTRING,

WA_TOA_DARA TYPE TOA_DARA,

FP_DOCPARAMS TYPE SFPDOCPARAMS,
FP_FORMOUTPUT TYPE FPFORMOUTPUT,

IT0023 TYPE TABLE OF ZHRSGRJL_0023 WITH HEADER LINE,
IT0021 TYPE TABLE OF ZHRSGRJL_0021 WITH HEADER LINE.

LOGFILEOBJ = CL_LSO_LOGFILE=>GET_INSTANCE( CL_LSO_LOGFILE=>CO_HANDLE_CP ).

READ TABLE Z01 INDEX P_TB_INDEX.

PERFORM GET_IT_0023_0021 TABLES IT0023 IT0021.

CONCATENATE Z01-PERNR '0002' INTO SZ_OBJID.

CALL FUNCTION 'ARCHIV_GET_CONNECTIONS'
EXPORTING
OBJECTTYPE = 'PREL'
OBJECT_ID = SZ_OBJID
CLIENT = SY-MANDT
ARCHIV_ID = 'A2'
DOCUMENTTYPE = 'HRICOLFOTO'
* UNTIL_AR_DATE = SY-DATUM
IMPORTING
COUNT = ICOUNT
TABLES
CONNECTIONS = AR_CONNECTIONS
EXCEPTIONS
NOTHING_FOUND = 1
OTHERS = 2.

IF ICOUNT > 0.
READ TABLE AR_CONNECTIONS INDEX 1.


MOVE AR_CONNECTIONS-RESERVE TO AR_DOCCLASS.

CALL FUNCTION 'ARCHIVOBJECT_GET_BYTES'
EXPORTING
ARCHIV_ID = AR_CONNECTIONS-ARCHIV_ID
ARCHIV_DOC_ID = AR_CONNECTIONS-ARC_DOC_ID
DOCUMENT_TYPE = AR_DOCCLASS
LENGTH = 0
OFFSET = 0
TABLES
BINARCHIVOBJECT = BINDATA
EXCEPTIONS
ERROR_ARCHIV = 1
ERROR_COMMUNICATIONTABLE = 2
ERROR_KERNEL = 3
OTHERS = 4.

LOOP AT BINDATA.
CONCATENATE SZ_XSTRING BINDATA-LINE INTO SZ_XSTRING IN BYTE MODE.
ENDLOOP.

Z01-MIMETYPE = AR_DOCCLASS.
Z01-PHOTO = SZ_XSTRING.

ENDIF.

IE_OUTPUTPARAM-DEVICE = 'PRINTER'.
IE_OUTPUTPARAM-NODIALOG = 'X'.
*IE_OUTPUTPARAM-DEST = 'ZPDF'.
*IE_OUTPUTPARAM-REQNEW = 'X'.
*IE_OUTPUTPARAM-ARCMODE = 2.

CALL FUNCTION 'FP_JOB_OPEN'
CHANGING
IE_OUTPUTPARAMS = IE_OUTPUTPARAM
EXCEPTIONS
CANCEL = 1
USAGE_ERROR = 2
SYSTEM_ERROR = 3
INTERNAL_ERROR = 4
OTHERS = 5.

IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

I_NAME = 'ZHRIRESUMEPDF'.


CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
I_NAME = I_NAME
IMPORTING
E_FUNCNAME = I_FUNCNAME
* E_INTERFACE_TYPE =
.

*wa_toa_dara-mandant = sy-mandt.
*wa_toa_dara-sap_object = 'PREL'.
*wa_toa_dara-ar_object = 'HRIDIPLAPL'.
*concatenate learnerid objid into wa_toa_dara-object_id.
*wa_toa_dara-reserve = 'Commit'.

APPEND WA_TOA_DARA TO FP_DOCPARAMS-DARATAB.

CALL FUNCTION I_FUNCNAME
EXPORTING
/1BCDWB/DOCPARAMS = FP_DOCPARAMS
ZHREMPLOYEEINFO = Z01
TBL_PS0023 = IT0023[]
TBL_PS0021 = IT0021[]
IMPORTING
/1BCDWB/FORMOUTPUT = FP_FORMOUTPUT
EXCEPTIONS
USAGE_ERROR = 1
SYSTEM_ERROR = 2
INTERNAL_ERROR = 3.

IF SY-SUBRC NE 0.
IM_TEXT = ''.
CONCATENATE IM_TEXT I_FUNCNAME ',MSGNO:' SY-MSGNO INTO IM_TEXT.
CALL METHOD LOGFILEOBJ->WRITE_FREE_ENTRY
EXPORTING
IM_TEXT = IM_TEXT
FUNCTIONNAME = 'ZHRP0051F01'
IM_MSGTY = 'E'
IM_LEVEL = 3.
ENDIF.

CALL FUNCTION 'FP_JOB_CLOSE'
EXCEPTIONS
USAGE_ERROR = 1
SYSTEM_ERROR = 2
INTERNAL_ERROR = 3
OTHERS = 4.

ENDFORM. " PROCESS_COMMAND

你可能感兴趣的:(IE,FP)