24 Eylül 2011 Cumartesi

SAP/ABAP: AT SELECTION-SCREEN OUTPUT, MODIF ID, USER COMMAND

TYPE-POOLS: VRM.

PARAMETERS P_BUSAB LIKE T001S-BUSAB AS LISTBOX
VISIBLE LENGTH 20 OBLIGATORY USER-COMMAND COM MODIF ID MOD.

DATA: L_NAME TYPE VRM_ID,
      LI_LIST TYPE VRM_VALUES,
      L_VALUE LIKE LINE OF LI_LIST.

SELECTION-SCREEN BEGIN OF BLOCK SECIM2 WITH FRAME TITLE TEXT-001.
PARAMETERS: FILENAME LIKE RLGRAP-FILENAME DEFAULT 'C:\' MODIF ID MD1
OBLIGATORY.
SELECTION-SCREEN END OF BLOCK SECIM2.
AT SELECTION-SCREEN OUTPUT.

  PERFORM F4_VALUE_REQUEST_P_BUSAB.

  LOOP AT SCREEN.

    IF P_BUSAB NE '06' AND SCREEN-GROUP1 = 'MD1'.

      SCREEN-INVISIBLE = 1.
      SCREEN-ACTIVE = 0.
    ENDIF.

    MODIFY SCREEN.

  ENDLOOP.
*&---------------------------------------------------------------------*
*&      Form  f4_value_request_pa
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM F4_VALUE_REQUEST_P_BUSAB.

  DATA: L_NAME TYPE VRM_ID,
        LI_LIST TYPE VRM_VALUES,
        L_VALUE LIKE LINE OF LI_LIST.

  SELECT BUSAB SNAME
    FROM T001S
    INTO (L_VALUE-KEY, L_VALUE-TEXT).
    APPEND L_VALUE TO LI_LIST.
    CLEAR l_value.
  ENDSELECT.

  L_NAME = 'P_BUSAB'.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      ID              = L_NAME
      VALUES          = LI_LIST
    EXCEPTIONS
      ID_ILLEGAL_NAME = 1
      OTHERS          = 2.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM. " f4_value_request_tabname

SAP/ABAP: REUSE_ALV_FIELDCATALOG_MERGE & REUSE_ALV_GRID_DISPLAY

DATA: BEGIN OF GT_ITAB OCCURS 0,
.
.
.
.
 END OF GT_ITAB.

DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE ,
      GS_LAYOUT   TYPE SLIS_LAYOUT_ALV                      .
  PERFORM ALV
    USING 'GT_ITAB'.
*&---------------------------------------------------------------------*
*&      Form  ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM ALV USING P_TABNAME.

  FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
  DATA LV_CHAR(15).
  CONCATENATE P_TABNAME '[]' INTO LV_CHAR.
  ASSIGN (LV_CHAR) TO <TABLE>.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      I_PROGRAM_NAME         = SY-REPID
      I_INCLNAME             = SY-REPID
      I_INTERNAL_TABNAME     = P_TABNAME
    CHANGING
      CT_FIELDCAT            = GT_FIELDCAT[]
    EXCEPTIONS
      INCONSISTENT_INTERFACE = 1
      PROGRAM_ERROR          = 2
      OTHERS                 = 3.

 GS_LAYOUT-COLWIDTH_OPTIMIZE     = 'X' .
  GS_LAYOUT-ZEBRA                 = 'X'.
  GS_LAYOUT-DETAIL_INITIAL_LINES  = 'X'.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM       = SY-REPID
      IS_LAYOUT                = GS_LAYOUT
      IT_FIELDCAT              = GT_FIELDCAT[]
      I_SAVE                   = 'A'
      I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
      I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
    TABLES
      T_OUTTAB                 = <TABLE>
    EXCEPTIONS
      PROGRAM_ERROR            = 1
      OTHERS                   = 2.

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

ENDFORM.                    " ALV
*&---------------------------------------------------------------------*
*&      Form  set_pf_status
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->RT_EXTAB   text
*----------------------------------------------------------------------*
FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
  SET PF-STATUS 'BUTTONS'.
ENDFORM.                    "set_pf_status

*&---------------------------------------------------------------------*
*&      Form  user_command
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                        RS_SELFIELD TYPE SLIS_SELFIELD.
  CASE R_UCOMM.
    WHEN '&BACK'.
      LEAVE TO SCREEN 0.
    WHEN '&EXIT'.
      LEAVE PROGRAM.
    WHEN 'BAPI'.
      PERFORM BAPI.

  ENDCASE.
ENDFORM.                    "user_command

20 Eylül 2011 Salı

SAP/ABAP: CL_TABLE_EDITOR FM

REPORT  ZABAP_CL_TABLE_EDITOR_FM                .

DATA: BEGIN OF GS_MARA,
MATNR TYPE MARA-MATNR,
MTART TYPE MARA-MTART,
END OF GS_MARA,

GT_MARA LIKE TABLE OF GS_MARA.

SELECT MATNR MTART
FROM MARA
INTO TABLE GT_MARA
UP TO 10 ROWS.

CALL FUNCTION 'CL_TABLE_EDITOR'
EXPORTING
FIELDLENGTH = 200
HEADLINE    = 'MARAdan 20 adet kayit'
TABLES
INTTAB      = GT_MARA.

CLEAR GS_MARA.
LOOP AT GT_MARA INTO GS_MARA.
WRITE:/ GS_MARA-MATNR, GS_MARA-MTART.
ENDLOOP.

11 Eylül 2011 Pazar

SAP/ABAP: Dinamik Query

PARAMETERS: RB_HEPSI RADIOBUTTON GROUP RAD1 DEFAULT 'X',
                 RB_CIKAN RADIOBUTTON GROUP RAD1,
                 RB_CIKMA RADIOBUTTON GROUP RAD1.
...
  CLEAR: GV_WEAKT_QUERY.
  CASE 'X'.
    WHEN RB_HEPSI.
      WRITE:
      '( EKKO~WEAKT IS NOT NULL OR EKKO~WEAKT IS NULL )'
      TO GV_WEAKT_QUERY.
    WHEN RB_CIKAN.
      WRITE: '( EKKO~WEAKT IS NOT NULL )'
      TO GV_WEAKT_QUERY.
    WHEN RB_CIKMA.
      WRITE:  '( EKKO~WEAKT IS NULL )'
      TO GV_WEAKT_QUERY.
  ENDCASE.

...

  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE GT_VERI
    FROM EKKO AS EKKO
    INNER JOIN LFA1 AS LFA1
    ON EKKO~LIFNR = LFA1~LIFNR
    WHERE EKKO~AEDAT IN S_AEDAT
      AND EKKO~EKGRP IN S_EKGRP
      AND EKKO~LIFNR IN S_LIFNR
      AND (GV_WEAKT_QUERY)
      AND EKKO~BSART NE P_BSART
      AND EKKO~BSTYP EQ P_BSTYP.

8 Eylül 2011 Perşembe

SAP/ABAP: BAPI_ASSET_REVERSAL_POST FM

DATA: LS_ORIGINDOCREFERENCE TYPE          BAPI6037_DOC_REF,
LS_ORIGINDOCUMENTKEY  TYPE          BAPI6037_DOC_KEY,
LS_REVERSALDATA       TYPE          BAPI6037_REV_DATA,

LS_DOCUMENTREFERENCE  TYPE          BAPI6037_DOC_REF,
LS_RETURN             TYPE          BAPIRET2,


LT_ORIGINDOCREFERENCE TYPE TABLE OF BAPI6037_DOC_REF,
LT_ORIGINDOCUMENTKEY  TYPE TABLE OF BAPI6037_DOC_KEY,
LT_REVERSALDATA       TYPE TABLE OF BAPI6037_REV_DATA,

LT_DOCUMENTREFERENCE  TYPE TABLE OF BAPI6037_DOC_REF,
LT_RETURN             TYPE TABLE OF BAPIRET2.


DATA: LS_ZAA_PROMOSYON_DV   TYPE          ZAA_PROMOSYON_DV,
LT_ZAA_PROMOSYON_DV   TYPE TABLE OF ZAA_PROMOSYON_DV.

DATA: LV_CURRM              LIKE          BKPF-MONAT,
LV_CURRY              LIKE          BKPF-GJAHR,
LV_PREVM              LIKE          BKPF-MONAT,
LV_PREVY              LIKE          BKPF-GJAHR.


PARAMETERS: P_TRANS TYPE ZAA_PROMOSYON_DV-TRANSFER_NO.

SELECT SINGLE *
FROM ZAA_PROMOSYON_DV
INTO LS_ZAA_PROMOSYON_DV
WHERE TRANSFER_NO EQ P_TRANS.

*ls_ORIGINDOCREFERENCE-OBJ_TYPE   ="AWTYP"
*ls_ORIGINDOCREFERENCE-REF_DOC    ="AWREF"
*ls_ORIGINDOCREFERENCE-REF_ORG_UN ="AWORG"

CALL FUNCTION 'GET_CURRENT_YEAR'
EXPORTING
BUKRS         = 'MEYI'
DATE          = LS_ZAA_PROMOSYON_DV-BLDAT
IMPORTING
CURRM         = LV_CURRM
CURRY         = LV_CURRY
*   PREVM         = LV_PREVM
*   PREVY         = LV_PREVY
.

LS_ORIGINDOCUMENTKEY-COMP_CODE   = LS_ZAA_PROMOSYON_DV-BUKRS.
LS_ORIGINDOCUMENTKEY-AC_DOC_NO   = LS_ZAA_PROMOSYON_DV-BELNR.
LS_ORIGINDOCUMENTKEY-FISC_YEAR   = LV_CURRY."LS_ZAA_PROMOSYON_DV-GJAHR."

LS_REVERSALDATA-FISC_YEAR        = LV_CURRY.
LS_REVERSALDATA-PSTNG_DATE       = LS_ZAA_PROMOSYON_DV-BLDAT."SY-DATUM."
LS_REVERSALDATA-FIS_PERIOD       = LV_CURRM.
LS_REVERSALDATA-REASON_REV       = '02'.


CALL FUNCTION 'BAPI_ASSET_REVERSAL_POST'
EXPORTING
ORIGINDOCREFERENCE = LS_ORIGINDOCREFERENCE
ORIGINDOCUMENTKEY  = LS_ORIGINDOCUMENTKEY
REVERSALDATA       = LS_REVERSALDATA
IMPORTING
DOCUMENTREFERENCE  = LS_DOCUMENTREFERENCE
RETURN             = LS_RETURN.


IF LS_RETURN-TYPE NE 'E'.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

SAP/ABAP: BAPI_USER_GET_DETAIL FM

DATA: LS_ADDRESS LIKE BAPIADDR3,
LT_RETURN LIKE TABLE OF BAPIRET2.

CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
USERNAME = SY-UNAME
IMPORTING
ADDRESS  = LS_ADDRESS
TABLES
RETURN   = LT_RETURN.

7 Eylül 2011 Çarşamba

SAP/ABAP: Exclude buttons from selection-screen

AT SELECTION-SCREEN OUTPUT.

  DATA: it_ucomm TYPE TABLE OF sy-ucomm.

  APPEND :
    'PRIN' TO it_ucomm,  "for print
    'SPOS' TO it_ucomm,
    'ONLI' TO it_ucomm,  "for execute
    'E'    TO it_ucomm,  "for back
    'ENDE' TO it_ucomm,  "for exit
    'ECAN' TO it_ucomm.  "for cancel

  CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
    EXPORTING
      p_status  = sy-pfkey
    TABLES
      p_exclude = it_ucomm.

SAP/ABAP: AT SELECTION-SCREEN OUTPUT

AT SELECTION-SCREEN OUTPUT.

PERFORM F_GET_DONEM.
*&---------------------------------------------------------------------*
*&      Form  F_GET_DONEM
*&---------------------------------------------------------------------*
form f_get_donem.

if gv_initialization eq 'X'.

call function 'HR_JP_MONTH_BEGIN_END_DATE'
exporting
iv_date             = sy-datum
importing
ev_month_begin_date = gv_date_low
ev_month_end_date   = gv_date_high.

concatenate gv_date_low+4(2) '.' gv_date_low(4) into p_donem.

clear: gv_initialization.

endif.

endform.                    " F_GET_DONEM

İnsdroid

Sabahtan beri çatada çutada çatada çutada… Bitmedi yine de… Neyse, yolumuz uzun, toparlıyorum çantamı, adaptörü falan tıkıştırıyorum bir şe...