顯示具有 ABAP 標籤的文章。 顯示所有文章
顯示具有 ABAP 標籤的文章。 顯示所有文章

2014年4月29日 星期二

How to read Report selection screen field values before PAI field transport

Function: DYNP_VALUES_READ

How to got the field value when you still in selection screen manipulating, example code as below:
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vbeln.
*--- Update P_VSTEL
  dyfields-fieldname 'P_VSTEL'.
  APPEND dyfields.
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname     sy-cprog
      dynumb     sy-dynnr
    TABLES
      dynpfields dyfields.
  READ TABLE dyfields INDEX 1.

  IF dyfields-fieldvalue IS INITIAL.
    MESSAGE i899 WITH 'Please enter Shipping Point first!'.
    EXIT.
  ELSE.
    CLEARgr_vstel,  gr_vstel[],
           gt_lipov,  gt_lipov[],
           gt_dn,     gt_dn[].
    gr_vstel-sign   'I'.
    gr_vstel-option 'EQ'.
    gr_vstel-low    dyfields-fieldvalue.
    APPEND gr_vstel.
  ENDIF.

2013年2月4日 星期一

[Code] How to catching selection criteria

How to catching selection criteria

Example: 
  DATAselection_table LIKE rsparams OCCURS 0  WITH HEADER LINE.

  CLEAR selection_tableREFRESH selection_table.

* Get selection criteria
  CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'

[Code] How to reference whole itab by name

How to reference whole itab by name

Example: clearing all selection criteria
FORM screen_clearing_all .
  DATAselctab         LIKE rsscr    OCCURS 20 WITH HEADER LINE,
        itabname        TYPE c        LENGTH 30.

  FIELD-SYMBOLS<para> TYPE ANY,
                 <sele> TYPE ANY TABLE.

  CLEAR selctabREFRESH selctab.

* Get selection screen

2013年1月31日 星期四

[Code] How to use subquery to get correct record


Suppose ZSD001 is filled as below:
MATNR         DATAB           APPOINTFEE
----------------------------------------
MA12345       2008/12/01      500
MA12345       2009/12/01      1,000
MA12345       2009/12/15      2,000
Example Code:
SELECT SINGLE APPOINTFEE INTO GT_ITAB-APPOINTFEE
    FROM ZSD001
   WHERE MATNR = 'MA12345'
     AND DATAB = ( SELECT MAX( DATAB )
                       FROM ZSD001
                      WHERE MATNR EQ 'MA12345'
                        AND DATAB LE '20091202'
                 ).

* GT_ITAB-APPOINTFEE == 1,000

Another example: (paste from RVAUFSTA)
SELECT OBJNR FROM JSTO AS APPENDING CORRESPONDING FIELDS OF
                     TABLE ONR_TAB WHERE A~OBJNR LIKE SDCON-OBJNR_VB AND
                                         A~OBJNR IN R_S_OBJNR AND
                                         A~OBTYP EQ SDCON-HEADER AND
                                         A~STSMA NE STSMA_INI AND
             EXISTS SELECT OBJNR FROM JEST WHERE OBJNR EQ A~OBJNR AND
                     STAT LIKE 'E%' AND INACT EQ SPACE ORDER BY OBJNR.

2012年5月18日 星期五

[TIP] SAP User-Favorites Table

SAP User-Favorites Table

Table name is SMEN_BUFFC
FUNCTION MENU_FAVORITES_DOWNLOAD

2012年5月7日 星期一

2011年9月30日 星期五

[Func] TH_POPUP

跳出通知訊息窗

By Client + User ID :
  DATA: client  LIKE sy-mandt,
        user    LIKE sy-uname,
        message LIKE sm04dic-popupmsg

  CALL FUNCTION 'TH_POPUP'
    EXPORTING
      client               = client
      user                 = user
      message              = message

[BAPI] BAPI_CONTRACT_CREATEFROMDATA

使用 BAPI 建立 Contract

定義
* BAPI Define
  DATA: gw_so_header          LIKE bapisdhd1,
        gw_so_headerx         LIKE bapisdhd1x,
        gw_so_logic_switch    LIKE bapisdls,
        gv_so_doc_in          TYPE bapivbeln-vbeln,
        gv_so_doc_num         TYPE bapivbeln-vbeln,
        gt_so_return2         TYPE bapiret2,
        gt_so_partners        TYPE bapiparnr  OCCURS 0 WITH HEADER LINE,
        gt_so_items_in        TYPE bapisditm  OCCURS 0 WITH HEADER LINE,
        gt_so_items_inx       TYPE bapisditmx OCCURS 0 WITH HEADER LINE,
        gt_so_return1         TYPE bapiret2   OCCURS 0 WITH HEADER LINE,
        gt_so_conditions_in   TYPE bapicond   OCCURS 0 WITH HEADER LINE,
        gt_so_conditions_inx  TYPE bapicondx  OCCURS 0 WITH HEADER LINE.

夥伴功能

2011年9月14日 星期三

[ABAP] Connection Keeper for network idle

當閒置時間過長連線中斷

有時是因為系統參數 rdisp/gui_auto_logout 的關係,有時是因為網路設備的關係,當閒置時間超過設定時,就會中斷連線。

如果可以的話,修改系統參數、網路設備設定,是最直接有效的。

如果不行的話,可以參考底下的程式。執行時輸入訊息傳輸的間隔秒數,要少於設定斷線的閒置秒數。


2011年8月24日 星期三

[Manual] CA - Drilldown Reporting


CA - Drilldown Reporting


With drilldown reporting, SAP provides you with an interactive information system to let you evaluate the data collected in your application. This information system is capable of analyzing all the data according to any of the characteristics that describe the data. You can also use any key figures you wish to categorize your data. You can display a number of objects for a given key figure, or a number of key figures for a given object. In addition, the system lets you carry out any number of variance analyses (such as plan/actual comparisons, fiscal year comparisons, comparisons of different objects, and so on).
You can produce both simple, data-directed lists (basic reports) and complex, formatted lists in drilldown reporting (form reports).
Drilldown report provides you with comfortable functions for navigating through your data. For example, you can jump to the next level of detail or the next report object on the same level, hide individual levels and switch between the detail and drilldown lists. It also provides a number of additional functions which let you process lists interactively (sorting, conditions, ranking lists, and so on). SAP Graphics, SAPmail and the Excel List Viewer are also integrated into drilldown reporting.
The drilldown functions are divided into three groups which differ in the number of functions available. That way each user can choose the functional level most suited for his requirements.
In addition to the online functions for displaying reports, drilldown reporting also provides functions which let you print reports. A number of formatting functions are available to let you determine the look of your printed reports (page breaks, headers and footers, underscores, and so on).
The menus and the functions available directly on the drilldown report make it easy to use the information system.

Source: CA - Drilldown Reporting

2011年6月14日 星期二

[Link] SWITCHING, ENHANCING, AND ADAPTING STANDARD PROGRAMS

The state-of-the art technology to enhance and adapt SAP standard objects is the new Enhancement Framework (available as of ABAP 7.0). You should use if you are sure that you have done everything in terms of customizing and still not completely accomplished what you need.

[Link] SAP ABAP Performance Tuning Tips & Tricks Introduction

In this world of SAP programming, ABAP is the universal language. In most of the projects, the focus is on getting a team of ABAP programmers as soon as possible, handing over the technical specifications to them and asking them to churn out the ABAP programs within the “given deadlines”.

[Code] READ_TEXT

SO Header
DATA  BEGIN OF ITLINE OCCURS 0.
      INCLUDE STRUCTURE TLINE.
DATA  END OF ITLINE.
DATA  G_VGBEL LIKE THEAD-TDNAME.

G_VGBEL = VBAK-VBELN.

CALL FUNCTION 'READ_TEXT'
  EXPORTING
    ID       = '0001'
    LANGUAGE = 'M'
    NAME     = G_VGBEL
    OBJECT   = 'VBBK'
  TABLES
    LINES    = ITLINE
  EXCEPTIONS
    ID       = 1
    OTHERS   = 2.
SO Item
DATA  BEGIN OF ITLINE OCCURS 0.
      INCLUDE STRUCTURE TLINE.
DATA  END OF ITLINE.

DATA  G_VGBEL LIKE THEAD-TDNAME.

CONCATENATE VBAP-VBELN VBAP-POSNR G_VGBEL.

CALL FUNCTION 'READ_TEXT'
  EXPORTING
    ID       = '0001'
    LANGUAGE = 'M'
    NAME     = G_VGBEL
    OBJECT   = 'VBBP'
  TABLES
    LINES    = ITLINE
  EXCEPTIONS
    ID       = 1
    OTHERS   = 2.

[Func] Converting Material Quantities To Different Unit Of Measure

單位轉換
Example code:
IF GT_ITAB-VRKME EQ GT_ITAB-KMEIN OR
   GT_ITAB-KMEIN EQ SPACE.
  LV_LFIMG = GT_ITAB-LFIMG.
ELSE.
  CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
    EXPORTING
      INPUT    = GT_ITAB-LFIMG
      KZMEINH  = 'X'
      MATNR    = GT_ITAB-MATNR
      MEINH    = GT_ITAB-VRKME
      MEINS    = GT_ITAB-KMEIN
      TYPE_UMR = '3'
    IMPORTING
      OUTPUT   = LV_LFIMG.
ENDIF.

[Link] USING SAP JAVA CONNECTOR TO GENERATE ABAP DOCUMENTATION


The tool presented in this article is simple yet useful. We needed documentation for the maintenance and support of an application, which has a Web and Java user interface, and ABAP backend. In the middle is the SAP® Java Connector also known as JCO. We used JCO to extract information from the SAP backend system.
The link address is:

[Code] Bills of material in the BAPI for create SO


使用 BAPI 建立含 BOM 的銷售訂單,重點在於先使用 BAPI_SALESORDER_SIMULATE 算出所有的 item no, 另外就是呼叫 BAPI_SALESORDER_CREATEFROMDAT2 時要使用 Exporting 參數 int_number_assignment = 'X'

Programming dynamic selections

You require two things before you can implement a dynamic selection in a logical database. One is a special statement in the database program's selection include (DBxxxSEL). This special statement ensures that the user can enter the corresponding selection criterion. You enter the selection criterion for a dynamic selection in a different way from simply parameters or selection tables, and the program also evaluates it in a different way. Therefore, the selection statement must be tailored to the paritcular table so that the table can evalutate this selection criterion. This section will introduce you to the statements you require in more detail.

[Code] Lock Mechanism


Lock:
CALL FUNCTION 'ENQUEUE_E_TRDIR'
  EXPORTING
    name           = 'PROGRAM_RUNNING'
    _scope         = '1'
  EXCEPTIONS
    foreign_lock   = 1
    system_failure = 2
    OTHERS         = 3.
IF sy-subrc <> 0.
  CALL FUNCTION 'DEQUEUE_ALL'.
  MESSAGE e000(zsd01) WITH 'Err: Program running!'.
ENDIF.
Unlock:
CALL FUNCTION 'DEQUEUE_ALL'.

Reference Manual: