|| 您当前的位置:首页 > SAP HR资源网

ABAP--批量建立员工照片关联程序参考代码

来源:  作者:  (查看评论)

REPORT ZHRLPHOTO NO STANDARD PAGE HEADING .
TABLES: TOAHR, PA0001.
INFOTYPES: 0000, 0001.
PARAMETERS:
PPFNAME LIKE TOAHR-ARC_DOC_ID default '%path% '." <---supply the specifi path

DATA:
PNUM LIKE PA0000-PERNR,
PFNAME LIKE TOAHR-ARC_DOC_ID,
PVAR LIKE TOAHR-ARC_DOC_ID,
PVAR1 LIKE TOAHR-ARC_DOC_ID,
PSAP_OBJ LIKE TOAHR-SAP_OBJECT VALUE 'PREL',
PARC_ID LIKE TOAHR-ARCHIV_ID VALUE 'HR',
PDOC_TYP LIKE TOAHR-AR_OBJECT VALUE 'Z_HRPHOTO',
PDOC_CLS LIKE TOAHR-RESERVE VALUE 'JPG'.

DATA: BEGIN OF ITAB OCCURS 1000,
PERNR LIKE PA0001-PERNR,
ENAME LIKE PA0001-ENAME,
END OF ITAB.

TOAHR-SAP_OBJECT = PSAP_OBJ.
TOAHR-ARCHIV_ID = PARC_ID.
TOAHR-AR_OBJECT = PDOC_TYP.
TOAHR-AR_DATE = SY-DATUM.
TOAHR-RESERVE = PDOC_CLS.

START-OF-SELECTION.

  SELECT * FROM PA0001
  WHERE BEGDA <= SY-DATUM AND ENDDA >= SY-DATUM
  AND PERNR > 0.
    MOVE-CORRESPONDING PA0001 TO ITAB.
    APPEND ITAB.
  ENDSELECT.

  LOOP AT ITAB.
    WRITE:/ ITAB-PERNR, ITAB-ENAME.
    CONCATENATE PPFNAME ITAB-PERNR '.jpg'
    INTO PVAR.

    SELECT SINGLE ARC_DOC_ID INTO PVAR1 FROM TOAHR
    WHERE SAP_OBJECT = PSAP_OBJ
    AND AR_OBJECT = PDOC_TYP
    AND ARCHIV_ID = PARC_ID
    AND RESERVE = PDOC_CLS
    AND ARC_DOC_ID = PVAR.

    IF SY-SUBRC <> 0.
      TOAHR-SAP_OBJECT = PSAP_OBJ.
      TOAHR-ARCHIV_ID = PARC_ID.
      toahr-arc_doc_id = pvar.
      TOAHR-AR_OBJECT = PDOC_TYP.
      TOAHR-AR_DATE = SY-DATUM.
      TOAHR-RESERVE = PDOC_CLS.
      concatenate itab-pernr ' 00000000' into toahr-object_id.

      INSERT TOAHR.
      write : 'Record successfully inserted.'.
    ELSE.
      WRITE: 'Record already exist'.

    ENDIF.
  ENDLOOP.

考试辅导
最近更新内容
Google广告