레이블이 ABAP인 게시물을 표시합니다. 모든 게시물 표시
레이블이 ABAP인 게시물을 표시합니다. 모든 게시물 표시

2026년 1월 14일 수요일

[ABAP]_인터널 테이블을 가변 필드로 사용하기

  FIELD-SYMBOLS<FS_TABLE> TYPE STANDARD TABLE,
                 <FS_WA>    TYPE ANY,
                 <FS_FIELD> TYPE ANY.

  DATA LO_STRUCTDESCR  TYPE REF TO CL_ABAP_STRUCTDESCR,
         LO_TABLEDESCR   TYPE REF TO CL_ABAP_TABLEDESCR,
         LT_COMP         TYPE CL_ABAP_STRUCTDESCR=>COMPONENT_TABLE,
         LS_COMP         TYPE CL_ABAP_STRUCTDESCR=>COMPONENT,
         LT_DATA         TYPE REF TO DATA,
         LS_DATA         TYPE REF TO DATA.

  DATA BEGIN OF LT_MARA OCCURS 0,
         MATNR      LIKE MARA-MATNR,
         MAKTX      LIKE MAKT-MAKTX,
         GROES      LIKE MARA-GROES,
         MEINS      LIKE MARA-MEINS,
         END OF LT_MARA.

*  "사용될 필드를 선언
  LS_COMP-NAME 'MATNR'.
  LS_COMP-TYPE CL_ABAP_ELEMDESCR=>GET_C18 ).
  APPEND LS_COMP TO LT_COMP.

  LS_COMP-NAME 'MAKTX'.
  LS_COMP-TYPE CL_ABAP_ELEMDESCR=>GET_C18 ).
  APPEND LS_COMP TO LT_COMP.

  LS_COMP-NAME 'GROES'.
  LS_COMP-TYPE CL_ABAP_ELEMDESCR=>GET_C18 ).
  APPEND LS_COMP TO LT_COMP.

  LS_COMP-NAME 'MEINS'.
  LS_COMP-TYPE CL_ABAP_ELEMDESCR=>GET_C18 ).
  APPEND LS_COMP TO LT_COMP.

  SELECT A~MATNR A~GROES A~MEINS B~MAKTX
    INTO CORRESPONDING FIELDS OF TABLE LT_MARA
    FROM MARA AS A
    JOIN MAKT AS B
      ON A~MATNR EQ B~MATNR
     AND B~SPRAS EQ 'E'
    UP TO 200 ROWS.

" 3. 구조 타입 및 테이블 타입 생성
  LO_STRUCTDESCR CL_ABAP_STRUCTDESCR=>CREATELT_COMP ).
  LO_TABLEDESCR  CL_ABAP_TABLEDESCR=>CREATEP_LINE_TYPE LO_STRUCTDESCR ).

*"선언된 구조체를 LT_DATA에 ASSIGN 처리
  CREATE DATA LT_DATA TYPE HANDLE LO_TABLEDESCR.
  ASSIGN LT_DATA->TO <FS_TABLE>.

  LOOP AT LT_MARA.
    CREATE DATA LS_DATA TYPE HANDLE LO_STRUCTDESCR.
    ASSIGN LS_DATA->TO <FS_WA>.

*   "LT_DATA에 ASSIGN된 필드를 찾아 데이터를 입력 처리함.
    ASSIGN COMPONENT 'MATNR' OF STRUCTURE <FS_WA> TO <FS_FIELD>.
    <FS_FIELD> LT_MARA-MATNR.

    ASSIGN COMPONENT 'MAKTX' OF STRUCTURE <FS_WA> TO <FS_FIELD>.
    <FS_FIELD> LT_MARA-MAKTX.

    ASSIGN COMPONENT 'GROES' OF STRUCTURE <FS_WA> TO <FS_FIELD>.
    <FS_FIELD> LT_MARA-GROES.

    ASSIGN COMPONENT 'MEINS' OF STRUCTURE <FS_WA> TO <FS_FIELD>.
    <FS_FIELD> LT_MARA-MEINS.

    APPEND <FS_WA> TO <FS_TABLE>.
  ENDLOOP.

  BREAK-POINT.
 

실행으로 생성된 인터널 테이블 구조


 

2025년 12월 18일 목요일

[ABAP] Selection Screen에서 TABSTRIP 사용하기

 

 탭을 TAB_BLK로 선언(2개의 TAB(TAB1/TAB2))

SELECTION-SCREEN BEGIN OF TABBED BLOCK TAB_BLK FOR 10 LINES.
  SELECTION-SCREEN TAB (20TAB1 USER-COMMAND TAB1
    DEFAULT SCREEN 1001.
  SELECTION-SCREEN TAB (20TAB2 USER-COMMAND TAB2
    DEFAULT SCREEN 1002.
SELECTION-SCREEN END OF BLOCK TAB_BLK.

 

개별 TAB에 대한 조회 조건 선언 

SELECTION-SCREEN BEGIN OF SCREEN 1001 AS SUBSCREEN.
  SELECT-OPTIONS S_LIFNR  FOR EINA-LIFNR,
                   S_MATNR  FOR EINA-MATNR,
                   S_EKORG  FOR EINE-EKORG,
                   S_WERKS  FOR EINE-WERKS,
                   S_ESOKZ  FOR EINE-ESOKZ.

 SELECTION-SCREEN END OF SCREEN 1001.

SELECTION-SCREEN BEGIN OF SCREEN 1002 AS SUBSCREEN.
  PARAMETERS     P_DATUM  TYPE SY-DATUM.
SELECTION-SCREEN END OF SCREEN 1002.

 

 개별 탭에 대한 이름 선언

INITIALIZATION.
  TAB1 'Inforecord'.
  TAB2 'Others'.

선택된 탭에 따른 실행 프로그램 선언 

START-OF-SELECTION. 

  IF TAB_BLK-ACTIVETAB EQ 'TAB1'.
    PERFORM SELECT_DATA1.
  ELSE.
    
PERFORM SELECT_DATA2.
  ENDIF.

 실행결과


 

2025년 3월 4일 화요일

[ABAP]_BOM 역전개 프로그램

 

*&---------------------------------------------------------------------*
*& Report  INVERSE_BOM_EXPLOSION
*& Inverse BOM Explosion
*&---------------------------------------------------------------------*
*&
*& BOM 역전개  : 긁어서 테스트 해 보시기바랍니다.
*&---------------------------------------------------------------------*

REPORT  y_inverse_bom_explosion.


TABLES    :stas, mara, makt, marc, t179t.

TYPE-POOLS: slis.

TYPES: BEGIN OF ty_1,
         vwalt(2)     TYPE c,
         matnr        TYPE marc-matnr,
         menge        TYPE p DECIMALS 0,
       END   OF ty_1,

       BEGIN OF ty_2,
         matnr        TYPE stpov-matnr,
         vwalt(2)     TYPE c,
         pmatnr       TYPE stpov-matnr,
         maktx        TYPE stpov-ojtxb,
         maktx1       TYPE stpov-ojtxb,
         menge        TYPE p DECIMALS 0,
         vtext        TYPE t179t-vtext,
       END   OF ty_2.

DATA : wa_store       TYPE ty_2,
       wa_gather      TYPE  ty_1,
       wa_stpov       TYPE stpov,
       wa_gather2     TYPE ty_1.


DATA : it_store       TYPE TABLE OF ty_2,
       it_gather      TYPE TABLE OF ty_1,
       it_gather2     TYPE TABLE OF ty_1,
       it_list        TYPE TABLE OF stpov,
       it_equicat     TYPE TABLE OF cscequi,
       it_kndcat      TYPE TABLE OF cscknd,
       it_matcat      TYPE TABLE OF cscmat,
       it_stdcat      TYPE TABLE OF cscstd,
       it_tplcat      TYPE TABLE OF csctpl.

DATA : g_partno       TYPE marc-matnr.
DATA : g_valdat       TYPE sy-datum.
DATA : g_lang         TYPE sy-langu.
DATA : g_index        TYPE sy-tabix.
DATA : g_cnt          TYPE sy-tfill.
DATA : g_repid        TYPE sy-repid.
DATA : g_initmenge(1) TYPE p DECIMALS 0 VALUE 1.
DATA : g_altbom(2)    TYPE c VALUE '01'.
DATA : g_abaptrue(1)  TYPE c VALUE 'X'.


DATA : wk_layout      TYPE slis_layout_alv,
       alvfld         TYPE slis_fieldcat_alv,
       fieldcat       TYPE TABLE OF slis_fieldcat_alv,
       i_sort         TYPE slis_t_sortinfo_alv,
       w_sort         LIKE LINE OF i_sort.


SELECT-OPTIONS:
       so_matnr     FOR  marc-matnr NO INTERVALS OBLIGATORY.
PARAMETERS:
       p_werks      TYPE marc-werks OBLIGATORY.

DEFINE alv_spec.

  alvfld-fieldname = &1.
  alvfld-seltext_m = &2.
  alvfld-tabname   = 'IT_STORE'.

  case &1.
    when 'VWALT'.
      alvfld-no_zero     = g_abaptrue.
    when 'MATNR'.
      w_sort-fieldname   = &1.
      w_sort-up          = g_abaptrue.
      w_sort-subtot      = g_abaptrue.
      append w_sort     to i_sort.
      clear w_sort.
    when 'MAKTX'.
      w_sort-fieldname   = &1.
      w_sort-down        = g_abaptrue.
      append w_sort     to i_sort.
      clear w_sort.
    when 'MENGE'.
      alvfld-emphasize   = 'C310'.
  endcase.

  append alvfld to fieldcat.
  clear  alvfld.

END-OF-DEFINITION.

*

INITIALIZATION.

  g_valdat = sy-datum.
  g_lang = sy-langu.
  g_repid = sy-repid.

  alv_spec 'VWALT' 'Alternative BOM'.
  alv_spec 'MATNR' 'Child_Partno'.
  alv_spec 'MAKTX' 'Child_Text'.
  alv_spec 'MENGE' 'Qty Required'.
  alv_spec 'PMATNR' 'Parent_Partno'.
  alv_spec 'MAKTX1' 'Parent_Text'.

  wk_layout-colwidth_optimize = g_abaptrue.
  wk_layout-zebra             = g_abaptrue.
  wk_layout-no_vline          = g_abaptrue.
  wk_layout-no_hline          = g_abaptrue.
  wk_layout-window_titlebar   =
           'INVERSE BILL OF MATERIAL MATRIX EXPLOSION' .

*

START-OF-SELECTION.

  LOOP AT so_matnr.
    CLEAR: g_index, g_cnt, wa_stpov, wa_gather, wa_store, g_partno.
    REFRESH: it_gather[],it_gather2[],it_equicat[],it_kndcat[].
    REFRESH: it_stdcat[],it_tplcat[],it_list[],it_matcat[].
    g_partno          = so_matnr-low.
    wa_gather-matnr   = so_matnr-low.
    wa_gather-menge   = g_initmenge.
    wa_gather-vwalt   = g_altbom.
    APPEND wa_gather TO it_gather[].
    CLEAR  wa_gather.
    PERFORM get_parts.
  ENDLOOP.

  CHECK it_store[] IS NOT INITIAL.
  PERFORM get_model_child_texts.
  SORT it_store[] BY vwalt matnr ASCENDING.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = g_repid
      is_layout          = wk_layout
      it_fieldcat        = fieldcat[]
      it_sort            = i_sort[]
    TABLES
      t_outtab           = it_store[].


*&---------------------------------------------------------------------*
*&      Form  GET_PARTS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_parts .

  CLEAR g_cnt.
  DESCRIBE TABLE it_gather LINES g_cnt.
  IF g_cnt = 0.
    EXIT.
  ENDIF.

  LOOP AT it_gather INTO wa_gather.

    CALL FUNCTION 'CS_WHERE_USED_MAT'
      EXPORTING
        datub                      = g_valdat
        datuv                      = g_valdat
        matnr                      = wa_gather-matnr
        werks                      = p_werks
      TABLES
        wultb                      = it_list[]
        equicat                    = it_equicat[]
        kndcat                     = it_kndcat[]
        matcat                     = it_matcat[]
        stdcat                     = it_stdcat[]
        tplcat                     = it_tplcat[]
      EXCEPTIONS
        call_invalid               = 1
        material_not_found         = 2
        no_where_used_rec_found    = 3
        no_where_used_rec_selected = 4
        no_where_used_rec_valid    = 5
        OTHERS                     = 6.
    CLEAR  g_cnt.
*Move to final itab
    DESCRIBE TABLE it_list[] LINES g_cnt.
    IF g_cnt = 0.
      wa_store-matnr = g_partno.
      MOVE wa_gather-matnr TO wa_store-pmatnr.
      MOVE wa_gather-vwalt TO wa_store-vwalt.
      wa_store-menge = wa_gather-menge.
      COLLECT wa_store   INTO it_store .
      CLEAR wa_store.
      CLEAR wa_gather.
    ELSE.
*Assign Alternative BOM if any ( VWALT )
      LOOP AT it_list INTO wa_stpov
              WHERE postp NE 'F' AND ( sumfg = space OR sumfg = 'x' ).
        g_index = sy-tabix.
        CHECK ( wa_stpov-vwalt = space ).
        MOVE wa_gather-vwalt TO wa_stpov-vwalt.
        MODIFY it_list INDEX g_index FROM wa_stpov TRANSPORTING vwalt.
      ENDLOOP.
      g_index = 0.
*Check if deleted from BOM Hierarchy
      LOOP AT it_list INTO wa_stpov
              WHERE postp NE 'F' AND ( sumfg = space OR sumfg = 'x' ).
        SELECT lkenz INTO (stas-lkenz)
               FROM  stas
               WHERE ( stlnr = wa_stpov-stlnr ) AND
                     ( stlkn = wa_stpov-stlkn ) AND
                     ( lkenz = g_abaptrue ).
          EXIT.
        ENDSELECT.

        IF sy-subrc NE 0.
*Material Master Deletion indicator check
          SELECT matnr INTO (mara-matnr)
                 FROM  mara
                 WHERE ( matnr EQ wa_stpov-matnr ) AND
                       ( lvorm EQ space ).
            EXIT.
          ENDSELECT.

          IF sy-subrc EQ 0.
*Prepare it_list for next level
            MOVE wa_stpov-matnr  TO wa_gather2-matnr.
            MOVE wa_stpov-vwalt  TO wa_gather2-vwalt.
            wa_gather2-menge = wa_stpov-menge * wa_gather-menge.
            COLLECT wa_gather2 INTO it_gather2.
            CLEAR   wa_gather2.
          ENDIF.

        ENDIF.

      ENDLOOP.

    ENDIF.
    REFRESH it_list[].
  ENDLOOP.

  it_gather[] = it_gather2[].
  REFRESH it_gather2[].
*Recursive process for exploding next level values
  PERFORM get_parts.

ENDFORM.                    "get_parts

*&---------------------------------------------------------------------*
*&      Form  VALIDATE_ENTRIES
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM validate_entries .

  DESCRIBE TABLE so_matnr[] LINES g_cnt.

  DO g_cnt TIMES.
    g_index = sy-index.
    READ TABLE so_matnr INDEX g_index.
    CHECK ( sy-subrc EQ 0 ).
    MOVE so_matnr-low TO g_partno.
    SELECT mara~matnr INTO (mara-matnr)
           FROM  mara INNER JOIN marc ON ( mara~matnr = marc~matnr )
           WHERE ( mara~matnr EQ g_partno ) AND
                 ( mara~mtart EQ 'HALB' )   AND
                 ( mara~lvorm EQ space )    AND
                 ( marc~werks EQ p_werks )  AND
                 ( marc~lvorm EQ space ).
      EXIT.
    ENDSELECT.
    CHECK ( sy-subrc NE 0 ).
    MESSAGE e983(zpp) WITH g_partno.
    EXIT.
  ENDDO.

ENDFORM.                    " VALIDATE_ENTRIES

*&---------------------------------------------------------------------*
*&      Form  GET_CHILD_TEXTS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_model_child_texts .

  TYPES:  BEGIN OF ty_makt,
            matnr        TYPE makt-matnr,
            maktx        TYPE makt-maktx,
          END   OF ty_makt.

  DATA : wa_makt         TYPE ty_makt,
         it_makt         TYPE TABLE OF ty_makt.

  SELECT matnr maktx
         FROM  makt  INTO TABLE it_makt
         FOR ALL ENTRIES IN it_store
         WHERE matnr = it_store-matnr
         AND   spras = g_lang.
  SELECT matnr maktx
         FROM  makt  APPENDING TABLE it_makt
         FOR ALL ENTRIES IN it_store
         WHERE matnr = it_store-pmatnr
         AND   spras = g_lang.

  CHECK   it_makt[] IS NOT INITIAL.

  SORT it_store BY matnr pmatnr ASCENDING.

  LOOP AT it_store INTO wa_store.

    g_index = sy-tabix.
    AT NEW matnr.
      READ TABLE it_makt[] INTO wa_makt WITH KEY matnr = wa_store-matnr
                           TRANSPORTING maktx.
      CHECK ( sy-subrc EQ 0 ).
      READ TABLE it_store INTO wa_store INDEX g_index.
      IF ( sy-subrc EQ 0 ).
        MOVE wa_makt-maktx TO wa_store-maktx.
        MODIFY it_store FROM wa_store TRANSPORTING maktx
                        WHERE ( matnr = wa_store-matnr ).
      ENDIF.
    ENDAT.
    READ TABLE it_makt[] INTO wa_makt WITH KEY matnr = wa_store-pmatnr
                         TRANSPORTING maktx.
    CHECK ( sy-subrc EQ 0 ).
    MOVE wa_makt-maktx TO wa_store-maktx1.
    MODIFY it_store INDEX g_index FROM wa_store TRANSPORTING maktx1.

  ENDLOOP.

ENDFORM.                    " GET_CHILD_TEXTS

2024년 5월 9일 목요일

[ABAP]_ABAP 소스 다운로드 프로그램

 [ 소스다운 ]   사용법

프로그램은 charset을 EUC-KR로 적용한 것으로 실행시 한글이 깨질경우 SAPGUI 설정을 

아래와 같이 변경해야 한다.


 

2023년 11월 7일 화요일

[ABAP]_엑셀 다운로드시 매크로 관련 오류

 [ 출처 : https://answers.sap.com/ ]


As per SAP Note 3247649 , the certificate needs to be installed manually under Trusted Publishers by each user or can be done through group policies. In order to get the certificate you need to at least have any one specific user/system who can export the certificate from the templates present in attachment of SAP Note 1992004 and also make sure the steps are performed in system.


[ 출처 : https://help.sap.com/ ]

1 - SAP SE certificate

  • The SAP SE certificate is delivered with the front end installation.
  • You can find the SAP SE certificate here: 
      • MS Excel > Options > Trust Center > Trust Center Settings > Trusted Publishers
      • MS Internet Explorer > Internet Options > Content > Certificates > TAB Trusted Publishers
  • On the "General" tab , you can check the validity.
  • On the "Certification Path" tab ,the path should be displayed as shown in following screenshot and the message "This certificate is OK" should be shown:
















2 - How to remove an expired SAP SE certificate?

  • Check folder C:\Program Files (x86)\SAP\Business Explorer\BI you can find the file BExAddin.dll. In the context menu for this file open the properties and switch to tab "Digital Signatures". You will find the SAP SE certificate. Press the button "Details" and then button "View Certificate" to see the validity of this certificate. As long any file has the "SAP SE certificate", irrelevant of the validity date, you can be assured that the file is a part of SAP certified software. The validity only shows the time period that SAP can use this certificate to certify a file. 



















  • Now you can find the expired SAP public key in Internet Explorer, Microsoft Edge or Excel Options under Trusted Publisher. The key is updated according to the setting/rules/option maintained in operating system.
  • If the validity of this key is expired, you can remove the key following these steps: 
  1. Start Microsoft Edge
  2. Open More Tools > Internet Options > on TAB Content > press button Certificates.  
  3. Under Trusted Publisher select SAP SE certificate and press button Remove:

3 - How to import the SAP SE certificate manually?

If you cannot find the certificate or you want to replace an expired certificate perform these steps:

  1. In Microsoft Edge > More Tools > Internet Options > Advanced tab, activate the flag "Check for publisher's certificate revocation":

  2. In Excel > Trust Center make sure that the following properties are active:
    1. Add-ins:
      1. [x] Require Application Add-ins to be signed by Trusted Publisher:


    2. Macro Settings according note 1962327
      1. (o) Disable all macros except digitally signed macros
      2. [x] Trust access to the VBA project object model:


  3. Close Internet Explorer and Excel.
  4. RESTART THE WORKSTATION
  5. Confirm the settings are still there on Excel and proceed
  6. Open folder C:\Program Files (x86)\Common Files\SAP Shared\BW.
  7. Start BExAnalyzer.xla file.
  8. MS Excel opens and a MS Excel Security PopUp asks for confirmation:


  9. Press button 'Trust all from publisher'. This imports the SAP SE certificate under the Trusted Publishers path.

Note:

  • Each certificate has a limited validity, it expires on a certain date. A new certificate with updated/extended validity is delivered with the BEx front end patch (see: Current BI ADDON for SAP GUI 760).
  • SAP releases the next patch before the old certificate expires, so you just have to install the newest patch to have a valid certificate.
  • If the root certificate 'VeriSign Class 3 Code Signing 2010 CA' has been expired, you will have to update it as described in note 711648.

 

4 - Certificates in workbooks

  • A new created workbook which is based on the SAP default workbook is signed and saved with the current installed certificate. So in the workbook a certificate exists with a limited validity.
  • When opening an old workbook containing an expired certificate you will receive a warning from Excel stating that the certificate with which the workbook was signed has expired. The warning messages state that the signature is invalid. It is not really a problem since it is just informing you about the status of the workbook. You can still work with the workbook.
  • When you save a workbook containing an expired digital certificate Excel automatically removes the invalid certificate from the workbook before saving it.

Note:

  • The SAP delivered SAP Default Workbook contains macros. For security reasons this workbook has to be digitally signed so that customers know that the workbook is from SAP and safe to use.
  • Workbooks which have been created by the customer do not necessarily require a signature. The customer determines if the workbook should be saved with a digital signature or not. If it is saved with a digital signature then the signature is typically the signature of the customer whom the workbook belongs to.

Here is how you can find the workbook certificate/signature:

  • Open the workbook > press Alt+F11 > in MS VB navigate: Tools > Digital Signature





SAP Note 711648 - Macro certificate signature not verified

 

[ 출처 : https://answers.microsoft.com/ ]


Macros from the internet will be blocked by default in Office: Block macros from running in Office files from the Internet

https://docs.microsoft.com/en-us/DeployOffice/security/internet-macros-blocked#block-macros-from-running-in-office-files-from-the-internet

매크로 보안 관련하여 기본 디자인이 최근에 바뀌었습니다. 여기서 이 레지스트리가 ‘구성되지 않음’ 상태일 경우 원래는 Office 앱의 보안 센터 설정을 따라가는 것이 기본 디자인이었으나, 이제는 ‘구성되지 않음’ 상태인 경우에도 Office 앱의 보안 설정과 상관없이 차단하는 것으로 디자인이 바뀐 것으로 보입니다.

Windows Registry Editor Version 5.00

 

[HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\office\16.0\excel\security]

"blockcontentexecutionfrominternet"=dword:00000000

 

위 내용을 그대로 복사하여 메모장에 붙여넣고, .reg 파일로 저장한 뒤 실행하여 병합합니다.

(메모장에서 저장시 '파일 형식'을 모든 파일로 지정하고 파일 이름 뒤 .reg를 붙이면됩니다)

 

 

 

이후 재부팅한 뒤, 매크로 파일을 열어보는 작업을 진행해 보시기 바랍니다.

 

이 레지스트리는 인터넷에서 다운로드된 오피스 파일에 포함된 매크로를 차단하는 것을 명시적으로 사용하지 않게 설정합니다.

 

이렇게 하면 Office 프로그램이 Excel 보안 센터의 매크로 설정을 따르게끔 조치할 수 있을 것으로 보입니다.

 

 

 

 

 

또한 매크로 설정을 위와 같이 매크로를 사용하는 쪽으로 모두 변경해 주셔야 할 수 있습니다.

 

인터넷에서 다운로드 된 파일에 포함된 매크로는 기본적으로 차단되는 것이 Microsoft의 권장 사항이며, 아무 조건 없이 실행시키도록 구성하는 것은 컴퓨터 보안 측면에서 위험할 수도 있습니다.

Microsoft Community를 이용해주셔서 감사합니다.

안내 드린 답변이 도움이 되었기를 바라며, 문제가 해결되지 않았거나 추가 질문이 있으실 경우

[응답] 버튼을 눌러 답변 부탁드립니다.

감사합니다.

 

 

 

2022년 1월 7일 금요일

[ABAP]_PO Exit상에서 내용 변경 처리 하기

 PO User-Exit에서 데이터 변경 처리시 실 데이터에 업데이트 되지 않기에 별도 표준 테이블에

업데이트 처리하는 방법

프로그램별 표준 테이블 적용 대상이 틀림

 

  FIELD-SYMBOLS <FS> TYPE ANY.

  IF SY-TCODE 'ME21N' OR SY-TCODE 'ME22N'.
    LV_TABLE '(SAPLMEPO)POT[]'.
  ELSEIF SY-TCODE 'ME21' OR SY-TCODE 'ME22'.
    LV_TABLE '(SAPMM06E)POT[]'.
  ELSE.
    EXIT.
  ENDIF.

  LOOP AT TEKPO.

   데이터 처리 로직 추가..... 

    MODIFY TEKPO.
    CLEARTEKPO.
  ENDLOOP.

  ASSIGN (LV_TABLETO <FS>.
  <FS> TEKPO[].
  UNASSIGN <FS>.
 

2021년 4월 12일 월요일

[ABAP] 프로그램시 팁

 [ 출처 : https://sapyard.com/lazy-and-smart-abapers/ ]

Let us see what are the common shortcuts and helpers which smart ABAPers of this age (not lazy) have in the same old ABAP editor.

1. Copy the same line below the existing line i.e duplicate the statement.

Use Ctrl + D to copy duplicate lines just below it.
2. Copying multiple rows of one column and paste them. Remember only one column not all columns (copying all the columns is easy).
You can copy multiple rows of one column using Alt + drag your cursor.

Can you copy just one column in ABAP editor? Yes, we can.

Check the image below. Only constant lc_tab is sele
cted and the other columns of the other rows are not.

Press Alt + drag your cursor to left till the column end and then drag down.

Then press Ctrl+C and then go to the rows where you want to paste it.

You need to apply the same trick where you want to paste it. Check this image. You need to hold Alt and drag the cursor vertically down and right side to create space for the copied rows of one column.



Check the copied rows of one column are pasted (Ctrl + V) in your selected area.


SAP Techies

For ABAPers: Fun about ABAP for SAP HANA

This is quite handy when you have repetitive words to be written in multiple rows. In the above example, it is Tab separator constant. In another case, it might be key work TYPE to be written while BEGIN OF TYPE declaration. Also, you can copy field name and data element from SE11 structure/table and paste it into your editor and then use Alt + drag to add TYPE.

 Initially, you might find some difficulty selecting columns using the trick. Keep trying and using and in no time you would start appreciating it more and more. 🙂

Also Read: Back to Basics

3. Line Separators or Code Separators
If you need a dashed line in your code, it might be for separation of code or modularization or just for making your code pretty. Do you type ‘*’ or ‘”‘ and then press ‘-‘ till the end of the line? Sometimes you might want to use ***** asterisks to do the same. Do you press ‘*’ till the end?

You should be taking advantage of the code completion feature of SAP. Just type ‘*–‘ and you get suggestions. Similarly type ‘***’ and you get suggestions. Hit ‘TAB’ key and it writes the full code for you.

You might be using IF-ELSE, DO-ENDO, LOOP ENDLOOP, CASE ENDCASE auto completion. But have you ever used IF ELSE ENDIF? Just type ife, and you get the suggestion. In fact, you can make SAP auto suggest you for anything and everything you code. It is completely in your control.







Where can we find the list of all Code Completion short codes?



Click the small Options icon on the right-hand side bottom corner in your editor. You can control the timing and properties of Code Completion. Code Template would actually have the code which would be written when you hit TAB when code completion suggestion creeps in.

You can create your own custom Code Completion list and add them to the repository.

You might like this: Are you an ABAP Coder or a Programmer?

4. Program Templates
Whenever an ABAPer creates a new program, they have some codes which are needed in each and every program they created. Flower box, revision log, Selection Screen, Program Events etc. Usually, we refer to another program and copy the template.


Check, I am creating a fresh new program and start typing ZZ_TEMPLATE. As I complete the word the auto-completion is visible and when I hit ‘TAB‘ key, the whole program skeleton is written for me.

The idea is to have the template for all the needed areas. Flower box, revision log, selection screen, events. Now, once I have the template, I just give the correct program name, description, logs and change the selection screen fields. If I do not need checkbox or radio buttons declaration, I delete them.

Also Read: End to End Configuration and Implementation of Two SAP Fiori Apps with no Coding

I remember in some projects we had the custom Pattern saved and used for the same purpose.

But later I realised, SAP has provided a smart way to avoid creation of that custom Pattern (since Pattern is also a development which we need to save in transport or local). Click the same small Options icon again on the right-hand side bottom corner in your editor. Hit Code Templates ->Add -> Give the name & description -> OK.

Paste your template code and Save it. Now everyone using this development box can use your template to get the job done faster. 🙂



Note : You can create one template for any work which you need very often, for example, selection screen snippet or file validation code or F4 Help code or MODIF id code etc. If you do not remember some syntax, just save a template for it and you do not need to remember it for life. 🙂

If you like the template and want to use it, you can copy from this file.  Template File.

But most projects will have their own flower box and templates, so use your project specific ones and save in the template.

Also Read: Do all ABAPers know Fixed Point Arithmetic?

5. Save the code in PDF format
Sometimes you want to take a backup of your code. Usually, we copy and paste it to a notepad or we go through Utilities -> More Utilities -> Download. But keeping your code back up in PDF format has its own beauty.

Just click the same icon at the bottom right of your editor, go to Keyboard option and look for File.ExportPDF short cut. For my case it is Shift + P. You can change this keys and assign your favourite keys to save as PDF. I have kept Shift + P unchanged.


Go to the desired program which you want to save in PDF. Hit Shit + P or any other keys if you have changed it. Save at the desired path you want.


 The code in PDF file always looks better. Isn’t it? 🙂

6. Have charm in the editor where you spend maximum time at work.
There should always be spice in your life. If you are bored of looking at the blue screen of your editors or just want to customize the fonts and colours for better readability or want different colours for fun or want something which soothes your eyes, check the below image.


This the current configuration of my workplace.

You can configure it for yourself using the same small icon on the right bottom corner of your editor. Choose Fonts and Colors. Below is the setting for my editor. Try and have fun!!


We have tried to reveal that small Options icon on your screen in this article. Hope after going through this post, that icon can no longer hide from your sharp eyes.

If you have some more short codes/cuts or tricks or any other interesting stuff, please do share it with us. If you have something which can help us be more smart/lazy, that would be more welcomed.


2020년 12월 22일 화요일

[SAP] SE78에서 등록한 이미지 다운 받기

[ 출처  : https://answers.sap.com/ ]

아래 프로그램으로 업로드 이미지 다운로드 가능함.

REPORT Z_DUMMY_ATG_3.

DATA : L_BYTECOUNT TYPE I,
       L_TDBTYPE   LIKE STXBITMAPS-TDBTYPE,
       L_CONTENT   TYPE STANDARD TABLE OF BAPICONTEN INITIAL SIZE 0.

DATA: GRAPHIC_SIZE TYPE I.

DATA: BEGIN OF GRAPHIC_TABLE OCCURS 0,
LINE(255) TYPE X,
END OF GRAPHIC_TABLE.

CALL FUNCTION 'SAPSCRIPT_GET_GRAPHIC_BDS'
  EXPORTING
    I_OBJECT       = 'GRAPHICS'
    I_NAME         = 'ZPRUEBA'
    I_ID           = 'BMAP'
    I_BTYPE        = 'BCOL'  "흑백일 경우 BMON임
  IMPORTING
    E_BYTECOUNT    = L_BYTECOUNT
  TABLES
    CONTENT        = L_CONTENT
  EXCEPTIONS
    NOT_FOUND      = 1
    BDS_GET_FAILED = 2
    BDS_NO_CONTENT = 3
    OTHERS         = 4.

CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP'
  EXPORTING
    OLD_FORMAT               = 'BDS'
    NEW_FORMAT               = 'BMP'
    BITMAP_FILE_BYTECOUNT_IN = L_BYTECOUNT
  IMPORTING
    BITMAP_FILE_BYTECOUNT    = GRAPHIC_SIZE
  TABLES
    BDS_BITMAP_FILE          = L_CONTENT
    BITMAP_FILE              = GRAPHIC_TABLE
  EXCEPTIONS
    OTHERS                   = 1.

CALL FUNCTION 'WS_DOWNLOAD'
  EXPORTING
    BIN_FILESIZE            = GRAPHIC_SIZE
    FILENAME                = 'C:\FirmaAsociado.bmp'
    FILETYPE                = 'BIN'
  TABLES
    DATA_TAB                = GRAPHIC_TABLE
  EXCEPTIONS
    INVALID_FILESIZE        = 1
    INVALID_TABLE_WIDTH     = 2
    INVALID_TYPE            = 3
    NO_BATCH                = 4
    UNKNOWN_ERROR           = 5
    GUI_REFUSE_FILETRANSFER = 6.

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

 

2020년 3월 27일 금요일

[ABAP] Field Catalog 항목

[출처 : http://blog.daum.net/rightvoice/791 ]


FieldName
소속
설명
ROW_POS
ALV 제어: 출력라인 (INTERNAL USE)
COL_POS Display Display되는 Column의 순서
생략시 입력순서대로 표시된다
TABNAME Control ALV의 Output Table의 Name을 넣어준다.
그런데 없어도 상관은 없다.
왜? 어차피 1개의 ALV는 1개의 FieldCatalog를 취하니까.
FIELDNAME Control(필수) ALV의 Output Table의 FieldName을 넣어준다.
여기가 Output Table 과 Catalog가 Match되는 방법이다
F4AVAILABL   필드에 출력도움말 유무점검 오류 : "No input help is available" 발생시
ref_table / ref_field를 Clear하면 된다.
REF_TABLE ABAP Dic(활용) ABAP Dic으로 부터 모든 데이타를 활용하게 설정할경우
(DOMAIN값을 참조할때도 반드시 설정되어 있어야 한다.)
ABAP Dic 참조하기위한 [테이블명]을 넣어준다.
REF_FIELD ABAP Dic(활용) ABAP Dic으로 부터 모든 데이타를 활용하게 설정할경우
(DOMAIN값을 참조할때도 반드시 설정되어 있어야 한다.)
ABAP Dic 참조하기위한 테이블의 [Field명]을 넣어준다.
DOMNAME ABAP Dic(활용) 윗 4개가 일치하지 않는경우,
DOMNAME이 어뚱한 놈을 바라보면 POPUP은 뜨는데 유효성 검사가 어뚱하게 걸리는 현상이 나타난다.
CURRENCY ABAP Dic(참조) 보여주려는 [숫자]의 소속이 [통화금액]인 경우
[고정통화]를 쓰는 경우 통화단위를 넣어준다. ex) [KRW]
CFIELDNAME ABAP Dic(참조) 보여주려는 [숫자]의 소속이 [통화금액]인 경우
[통화]를 가지고 있는 [FieldName]을 넣어준다.
=> [FieldName]이 FieldCatalog의 Member로 등록되어있어야 함.
(만약에 없는경우, [Data]수정시 오류가 발생함. )
QUANTITY ABAP Dic(참조) 보여주려는 [숫자]의 소속이 [단위수량]인 경우
[고정단위]를 쓰는 경우 수량단위를 넣어준다. ex) [Kg]
QFIELDNAME ABAP Dic(참조) 보여주려는 [숫자]의 소속이 [단위수량]인 경우
[단위]를 가지고 있는 [FieldName]을 넣어준다.
=> [FieldName]이 FieldCatalog의 Member로 등록되어있어야 함.
(만약에 없는경우, [Data]수정시 오류가 발생함. )
INTTYPE Control(필수) ABAP 데이타유형 (C,D,N,...)
JUST Display(추천) 화면표시 정렬 ( Left , Center , Right )
OUTPUTLEN Display(추천) 화면표시 문자의 열 너비
Layout-cwidth_opt = 'X' 설정시 무력화 된다.
COLTEXT (40) Display(필수) Column Header의 텍스트(오직 1개의 종류만 표시할때)
   SCRTEXT_L  (40) Display(선택)    Column Header의 텍스트(폭이 넓은경우 표시)
   SCRTEXT_M (20) Display(선택)    Column Header의 텍스트(폭이 중간인 경우 표시)
   SCRTEXT_S (10) Display(선택)    Column Header의 텍스트(폭이 좁은경우 표시)
   TOOLTIP(40) Display(선택) Column의 말풍선
NO_OUT Display(Variant설정) 초기화면 조회시에는 보이지 않도록
Variant설정시에는 Layout설정에 나타난다.
  TECH Display(Variant설정) 화면에서 아예 보이지 않는다.
HOTSPOT Display(선택)/Event연동 웹브라우저의 HyperLink처럼 동작하게 한다. Click Event처리
EDIT
(가장 중요한 설정항목중 하나임)
Display(편집) 해당 Field에 대해서 편집설정을 나타낸다.
Layout-edit = 'X' 설정시 무력화 된다.(하위개념임)
그밑에 Cell-Style의 Enable/Disable이 있음
CHECKBOX Display(편집) 체크박스로 보여준다.
DRDN_HNDL Display(편집) Dropdown List Handle/ 정수값을 입력해 주어야 한다
1개의 Field는 1개의 Dropdown List만을 보여줄때 사용
   DRDN_FIELD Display(편집) Dropdown List Field/ FieldName을 입력해 주어야 한다
1개의 Field는 다수의 Dropdown List를 보여줄수 있다.
   DRDN_ALIAS Display(편집) Dropdown List Handle( X 설정요망 )
User에게 코드를 보여주면 가독성이 떨어진다.
따라서 [코드:설명]이렇게 보여주기 원할때 사용한다
CHECKTABLE Display(편집) ABAP Dic에 의해 CheckTable이 설정되면 자동으로 F4활성
유효성 검사등이 수행된다.
이때 이값에 "!"을 넣어주면 임의편집을 가능하게할수있다
KEY Control(선택) 키필드로 선택(배경색이 자동으로 파랑색, Key역활을 시작함)
1. 필수 입력사항이다.
2. 한번 입력된 내용은 수정될 수 없다.
3. Key Value는 Unique해야 한다.
   KEY_SEL Control(선택) KEY로 설정한후 화면상의 Display하지않음, Variant에도 안나옴
FIX_COLUMN Control(선택) Column고정.  Hsplit 기능을 사용할 때 사용한다.
ROUND Display(숫자) 보여주려는 [숫자]의 소수점을 주어진 round 수만큼
좌측이로 이동한다.
결과숫치 =  기존숫자 / (10^(round) ) 의 역활을 한다.
숫치입력시 자동으로 나누기가 시행되므로 사용에 주의할것
Ex) 100.00 [Round = 2] => 1.00
NO_SIGN Display(숫자) 보여주려는 [숫자]의 부호를 표시하지 않는다.
NO_ZERO Display(숫자) 보여주려는 [숫자]가 0인경우 표시하지 않는다 [숫자]의 소속이 [통화금액][단위수량]인경우 자동으로 설정
DECIMALS_O Display(숫자) 보여주려는 [숫자]의 소숫점 자리수 설정. Decimals 설정을 같이 늘려주지 않으면 입력오류가 발생됨
   DECIMALS Display(숫자) 입력되는 [숫자]의 소숫점 자리수 설정.
LZERO Display(숫자) Data Type : N , ABAP Type : Numeric
문자형 숫자이므로 앞쪽에 빈공간에 "0"을 채워준다.
DO_SUM Display(숫자)/Sort연동 set_table_for_first_display
의 Sort설정이 되었을경우 중간합을 보여준다.
'X' 설정시 [총합]
'C' 설정시 [평균]을 보여준다.
EXPONENT
ALV 제어: 부동표현에 대한 지수
ICON Display(문자) 아이콘으로 출력할때
SYMBOL Display(문자) ALV 제어: 기호로 출력
EDIT_MASK Display(문자) 화면 Display시 편집마스크. Ex) "____/__/__"
EMPHASIZE Display(강조) Column(Field)를 시스템이 지정한 색상으로 강조한다
= 'C600' (개발자가 색상지정), = 'X' (시스템이 색상지정)
NO_SUM
ALV 제어: 열값에 관한 집합처리없음
TECH
ALV 컨트롤: 기술적 필드
CONVEXIT   변환루틴( Domain에 Exit가 걸린경우 해당정보를 제공한다 )
SELTEXT
ALV 제어: 다이얼로그 기능에 대한 열식별자
NO_CONVEXT
ALV 제어: 화면 Display시 변환종료를 고려하지 마십시오
ROLLNAME   ALV 제어: F1 도움말의 데이터 요소
Elment의 이름을 넣어주면된다. [Dynamic itab]이 설정기준이 된다.
DATATYPE   ABAP Dictionary 데이타유형
INTLEN   내부길이 (바이트단위)
LOWERCASE
소문자 사용/금지
REPTEXT
헤딩
HIER_LEVEL
ALV 컨트롤: 내부 사용
REPREP
ALV 컨트롤: 값은 rep./rep.intf에 대한 선택 기준입니다.
DOMNAME
도메인이름
SP_GROUP
그룹 키
DFIELDNAME
ALV 제어: 데이터베이스의 열 그룹에 대한 필드 이름
COL_ID
ALV 제어: 열 ID
AUTO_VALUE
ALV 제어: 자동값복사
VALEXI
고정값 존재
WEB_FIELD
ALV 제어: 내부 테이블 필드의 필드 이름
HREF_HNDL
정수
STYLE
ALV 제어: 스타일
STYLE2
ALV 제어: 스타일
STYLE3
ALV 제어: 스타일
STYLE4
ALV 제어: 스타일
DRDN_FIELD
ALV 제어: 내부 테이블 필드의 필드 이름
NO_MERGING
문자 필드 길이 1
H_FTYPE
ALV 트리 제어: 기능유형 (합계, 평균, 최대, 최소, ...)
COL_OPT
선택 열 최적화 엔트리
NO_INIT_CH
문자 필드 길이 1
TXT_FIELD
ALV 제어: 내부 테이블 필드의 필드 이름
ROUNDFIELD
ALV 제어: ROUND 사양을 가진 필드이름
DECMLFIELD
ALV 제어: DECIMALS 사양을 가진 필드이름
DD_OUTLEN
ALV 제어: 문자의 출력길이
COLDDICTXT
ALV 제어: DDIC 텍스트 참조 결정
SELDDICTXT
ALV 제어: DDIC 텍스트 참조 결정
TIPDDICTXT
ALV 제어: DDIC 텍스트 참조 결정



TECH_COL
ALV 컨트롤: 내부 사용
TECH_FORM
ALV 컨트롤: 내부 사용
TECH_COMP
ALV 컨트롤: 내부 사용
HIER_CPOS
ALV 제어: 계층구조적 열위치
H_COL_KEY
트리 컨트롤: 열 이름/항목 이름
H_SELECT
트리제어의 열을 선택할 수 있는지의 여부 지시
DD_ROLL
Data element (의미도메인)
DRAGDROPID
ALV 제어: 끌어옮기기 오브젝트에 대한 끌어옮기기 조정
MAC
문자 필드 길이 1
INDX_FIELD
정수
INDX_CFIEL
정수
INDX_QFIEL
정수
INDX_IFIEL
정수
INDX_ROUND
정수
INDX_DECML
정수
GET_STYLE
문자 필드 길이 1
MARK
문자 필드 길이 1