关于ABAP load

Note 1230076 - Generation of ABAP loads: Tips for the analysis

这个Note很有用,对于有时候transport为何不做generation,这个note的内容可以帮助你解释。
因为SAP只会generate具有load version的程序。

(0) 评论    (0) 引用   

DBIF_RSQL_INVALID_RSQL short dump

when we trying to retrive data by SE16 etc, we input tons of single values and might come into DBIF_RSQL_INVALID_RSQL short dump.

This is not a SAP error, it's due to open sql limitation.

You can find more detail in Note 13607 Termination of an ABAP with DBIF_RSQL_INVALID_RSQL


(1) 评论    (0) 引用   

[Collection]Master Data IDoc Message Type List

http://www.erpgenie.com/sapedi/message_types_masterdata.htm

General

Message types / IDoc types / BAPI

Vendor

CREMAS / CREMAS02

Customer

DEBMAS / DEBMAS03

Accounting

Message types / IDoc types / BAPI

G/L account

GLMAST / GLMAST01

Cost center

COSMAS / COSMAS01

Cost element

COELEM / COELEM01

Cost center group

COGRP1 / COGRP01

Cost element group

COGRP1 / COGRP01

Activity type

COAMAS / COAMAS01

Activity group

COGRP1 / COGRP01

Activity price

COACTV / COACTV01

Profit center

PRCMAS / PRCMAS01

Profit center group

COGRP1 / COGRP01

Profit center account group

COGRP1 / COGRP01

Logistics

Message types / IDoc types / BAPI

Article master

ARTMAS / ARTMAS02 / RetailMaterial.Clone

Additional

MMADDI / MMADDI01 / RetailMaterial.SaveAdditionalReplicas

Product catalog

PRDCAT / PRDCAT01

Product catalog item

PRDPOS / PRDPOS01

Price list

PRICAT / PRICAT01

Assortment

ASSORTMENT / ASSORTMENT01 / Assortment.SaveReplica

Material master

MATMAS / MATMAS03 - (See Template)

Service master

SRVMAS / SRVMAS01

Characteristic

CHRMAS / CHRMAS02

Class

CLSMAS / CLSMAS03

Classification

CLFMAS / CLFMAS01

Document

DOCMAS / DOCMAS04

Purchasing info record

INFREC / INFREC01

Conditions

COND_A / COND_A01

Order book

SRCLST / SRCLST01

Change master

ECMMAS / ECMMAS01

Bill of material

BOMMAT / BOMMAT01

Document BOM

BOMDOC / BOMDOC01

Work breakdown structure

Project / PROJECT01

Human Resources

Message types / IDoc types / BAPI

PA object type person

HRMD_A / HRMD_A03

PD object types

HRMD_A / HRMD_A03

Basis

Message types / IDoc types / BAPI

User master record

USERCLONE / USERCLONE01 / User.Clone


(0) 评论    (1) 引用   

Unit of Measurement notice when using ALE/IDoc

When we need to pass UoM to SAP by IDoc, we need to pass ISO Code, not internal UoM format.

The value is stored in T006 table.

Detailed info: Note 69063


(0) 评论    (1) 引用   

issue of importing info record using INFREC IDoc

INFREC don't update net price of info record, because it's stored in condition table KNOH and KNOP.

We have to load price condtion using CON_A after INFREC.


(0) 评论    (1) 引用   

BAS Business Adress Service

http://help.sap.com/saphelp_nw04/helpdata/en/c8/13b237b9a9a968e10000009b38f8cf/frameset.htm

Customer/Vendor Message type:ADRMAS
Process Code: BAPI

(0) 评论    (1) 引用   

失手造成无法登陆服务器,贱手!

为了演示SUSR0001这个logon sap的customer exit,我做了实现,可惜手太快,判断USER的时候,写的是小写,如果不是XXX,则全部CALL 'SYS_LOGOFF',结果可想而知,谁也别想登陆服务器了。
于是我直接进入到DB一层(我们用SQL SERVER2005)把REPOSRC中的ZXUSRU01删除,可是不行。
我发现,SAP实现一个customer exit的active&inactive是通过对表TFDIR中的CLIENT字段操作的,如果激活状态,字段值为C,如果是INACTIVE状态,字段值是空,我直接改了DB,还是不起作用。
正当我在折腾version management system表的时候,我突然想从sap management console试试。
找到R3SysLog,然后右键,all task-> analyse 登陆的画面弹出来了,输入用户名密码,直接进入了R/3...OMG,终于不用重装了。

(0) 评论    (1) 引用   

No logical path has been specified

When loaded WM bin master data by program RLPLAT00 using LSMW, i got error message "No logical path has been specified" at speficy files step.

As a result of RLPLAT00 needs logical file. We can run it directly and get this result from selection screen.

More detail info, please refer NOTE 753511

Summary

Symptom

The system issues an error message concerning the logical path or file when you perform the "Specify files" step in the Legacy System Migration Workbench (transaction LSMW), even though you have made the correct assignment in transaction FILE.

The error messages are listed below:

  • The logical path <PATH> does not point to the physical directory.
  • The logical file <FILE> is not assigned to the physical file.
  • The logical path <PATH> does not exist.
  • The logical path <PATH> does not exist for this operating system.


or

  • A logical path was not specified.

Other terms

Logical path, logical file, transaction FILE, LSM Workbench, /SAPDMC/LSMW_OBJ_060, batch input, direct input, BI, DI

Reason and Prerequisites

Some import interfaces that you can also use with transaction LSMW work with logical path and file names.

Transaction LSMW itself, however, works with physical file names. To be able to transfer the LSMW file with the converted data to the import program, you must specify a logical file name for the file with the converted data in addition to the physical file name. In this case, in the step "Specify files" for the converted data file, you obtain additional fields in which you must enter the logical path name and file name (choose "Change entry" for the converted data).

Solution

The error messages may be due to several causes. Check the following:

Have you maintained the logical path and logical file name and have you assigned them to the physical file specified in the "File" input field of transaction LSMW?
These settings are maintained in transaction FILE.

Note that you must also make an assignment to the physical path for the full specification of a logical path in transaction FILE. You must make this assignment for all potential syntax groups (groups of operating systems with the same syntax for file paths). Refer to the documentation for transaction FILE for additional information.

When you use logical file and path names, you must specify the name of the physical file with its path. If you have not specified any directory, you cannot assign any directory to the logical path in transaction FILE. In this case, the system uses the SAP Home directory on the application server by default. Bear in mind that the file name must not exceed the maximum length of 45 characters, including the path.

Up to LSMW Version 1.7.2 (*):
If the logical file name specified does not point to the physical file (although it should do so), the system adjusts the logical file name, that is, the information in transaction FILE is changed to the entries made in transaction LSMW. This may lead to unwanted side effects if the logical file is also used somewhere else. Therefore, SAP recommend that you always use separate logical paths and file names for transaction LSMW (the problem is corrected as of LSMW version 1.8.0, see below). If the logical file does not exist yet, it will be created upon request.

As of LSMW Version 1.8.0 (*):
Although the settings of the logical file are checked, they are no longer adjusted automatically as in Version 1.7.2 (see above). If there are inconsistencies, the system issues an error message. If the user is authorized to maintain logical paths and file names (as for transaction FILE: "Maintenance authorization for cross-client tables"), transaction LSMW can create the logical path, the file name and the file. Due to this automatic generation, the user no longer needs to make adjustments in transaction FILE. Therefore, we especially recommend this procedure.

(*):
To display the version of transaction LSMW, select "Extras" --> "Display LSMW version" in the main menu of the initial screen.
You should also bear in mind that as of Basis Release 6.20, that is, as of LSMW Version 4.0, transaction LSMW is no longer an add-on but is delivered with the standard system.


(1) 评论    (0) 引用   

BAPI_CUSTOMER*

The BAPIs of the function group V02D are intended exclusively for use in the SAP Online Store and the SAP Internet Sales R/3 Edition, that is you can create or change consumers from the SAP Online store and SAP Internet Sales R/3 Edition in the R/3 system. You cannot use them to create or change customer masters or consumers in the standard system; you can only do this using ALE or Batch Input.
When you use the above-mentioned BAPIs outside of SAP Online Store or SAP Internet Sales R/3 Edition, or with customer master records that were created or edited outside of the SAP Online Store or SAP Internet Sales R/3 Edition, there is a danger that you will lose data.


(0) 评论    (0) 引用   

Cross-system company code 1000 does not exist

如果使用了ALE/IDoc来分发数据,就可能涉及cross-company code

配置路径

SAP NetWeaver->Application Server->IDoc Interface / Application Link Enabling (ALE)->Modelling and Implementing Business Processes->Global Organizational Units

Global Organizational Units

There are global organizational units which must be named the same in all systems to avoid any errors occurring in the distributed environment. Local organizational units are assigned to global organizational units in the individual systems.

There are global organizational units for the organizational units:

    • Company code
    • Business area

If you want to use ALE, you have to assign the local organizational units to the global organizational units in your systems to ensure that they are used consistently in the distributed environment.

Cross-System Company Codes

Cross-system company codes are used in the distribution in financial accounting. There is exactly one central system for each cross-system company code in the distributed environment. One company code has to be assigned to this cross-system company code on each system involved in the distribution.

When sending an IDoc with company code-dependent data, the company code is replaced with the cross-system company code in all company code fields. When receiving this kind of IDoc the reverse conversion takes place on the target system.

In this section you maintain the cross-system company codes and allocate them to the local company codes.

Recommendation

    • The use of cross-system company codes and business areas in distributed financial accounting is a provisional measure. SAP reserves the right to replace this in a future release with a tool that allows a conversion for all the organizational units of the SAP system.
    • Therefore SAP recommends that you choose consistent identifiers for the company code and the cross-system company code.

Activities

    1. Create a cross-system company code.
    2. Assign the cross-system company code to a chart of accounts to which it is also assigned on the central system.
    This setting is needed on the decentral systems in order to determine the chart of accounts of the company code on the central system.
    3. Assign cross-system company codes to the local company codes.
    Specify the identifiers of the relevant cross-system company codes for each of the individual company codes.

(0) 评论    (0) 引用   

SAP Idoc control record信息

(0) 评论    (22) 引用   

SAP IDoc 相关事务码

Transaction Code Text
SALE Display ALE Customizing
SM59 RFC Destinations (Display/Maintain)
BD64 Maintenance of Distribution Model
BD82 Generate Partner Profiles
WE20 Partner Profiles
WE21 Port definition
WE30 IDoc Type Development ( View Segments of an IDOC )
WE60 IDOC segment field description
WE19 Test tool for IDOC Processing
WE05 IDOC Lists
WE09 Search for IDOC in Database
BD87 Status Monitor for ALE Messages (Process IDOC manually)
BD73 Start Error Handling for Non-Posted IDocs
WEDI IDOC and EDI Basis

Change Pointers:

BD50 Activate change pointer for message type
BD61 Activate Change pointer generally
BD52 Triggering table and field name
BD21 Creates and sends the Idoc for Change pointer method
BD59 Set the field for Filter in Distribution Model
BD95 Along with BD59 , used for setting a filter in Distribution model

Assigning FM to the outbound IDOC , and specifying Change
BD60
pointer Table and Object
BD56 Segment Filtering


Inbound IDOC:

WE81 Create Logical message types
WE82 Assign Messages for IDoc Type
WE31 Development IDoc Segment
WE57 Assignment of FM to Log, Message and IDoc Type
BD51 Characteristics of Inbound FM
WE42 Creating Inbound Process Code
BD67 Function modules for Inbound ALE-EDI


(0) 评论    (92) 引用   

SAP数据传输导入详解

由于在项目中要负责所有关键主数据的配置维护与数据导入,所以总结了一篇比较详尽的文档,主要参考了《SAP业务数据传输指南》并做了补充。主要有如下方面

  • LSMW的使用详解:包括使用SAP标准传输程序 使用BAPI和使用IDOC 3种主要方式
  • 总结了SAP常用的标准传输程序
  • SAP传输技术详解:包括批输入(batch input) 直接输入(direct input)和事务调用(call transaction)
  • 数据传输工作台简介(DXWB) 因为项目中大多数都使用LSMW,所以此工具制作了简要介绍
  • CATT的使用介绍 目前所欠缺的是eCATT的总结,此工具在我的项目中也会涉及,所以后续应该会有文档介绍

具体文档和图片请参照附件http://www.box.net/shared/7qpcfn8jl3


(0) 评论    (73) 引用   

可更改字段值的SAP List Report

*&---------------------------------------------------------------------*
*& Report ZDAVID_REPORT_01
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT zdavid_report_01.

DATA:wa_bsis TYPE bsis,
it_bsis TYPE TABLE OF bsis,
it_bsis_mod TYPE TABLE OF bsis.

START-OF-SELECTION.

SELECT *
INTO TABLE it_bsis
FROM bsis
UP TO 20 ROWS
WHERE sgtxt <> space.

END-OF-SELECTION.

SET PF-STATUS 'STATUS01'.
LOOP AT it_bsis INTO wa_bsis.
WRITE :/ wa_bsis-bukrs,
wa_bsis-hkont,
wa_bsis-gjahr,
wa_bsis-belnr,
wa_bsis-sgtxt INPUT ON.
ENDLOOP.

AT USER-COMMAND.
BREAK-POINT.
CASE sy-ucomm.
WHEN '&USR01'.
PERFORM frm_get_report_data.
WHEN OTHERS.
ENDCASE.

AT LINE-SELECTION.
WRITE: / sy-lisel.
*&---------------------------------------------------------------------*
*& Form frm_get_report_data
*&---------------------------------------------------------------------*
* Get revised report data
*----------------------------------------------------------------------*
FORM frm_get_report_data .

DATA: lc_lines TYPE i,
lc_index TYPE i.

DESCRIBE LIST NUMBER OF LINES lc_lines.
lc_lines = lc_lines - 2.
DO lc_lines TIMES.
IF sy-listi = 0.
lc_index = sy-index + 2.
READ LINE lc_index INDEX sy-listi FIELD VALUE wa_bsis-sgtxt .
MODIFY it_bsis FROM wa_bsis INDEX sy-index TRANSPORTING sgtxt.
ELSE.
READ LINE sy-index INDEX sy-listi FIELD VALUE wa_bsis-sgtxt .
MODIFY it_bsis FROM wa_bsis INDEX sy-index TRANSPORTING sgtxt.
ENDIF.
ENDDO.

LOOP AT it_bsis INTO wa_bsis.
WRITE :/ wa_bsis-bukrs,
wa_bsis-hkont,
wa_bsis-gjahr,
wa_bsis-belnr,
wa_bsis-sgtxt INPUT ON.
ENDLOOP.


ENDFORM. " frm_get_report_data


(0) 评论    (89) 引用   

SUBMIT一个ALV程序,判断是否成功

REPORT zdavid_submit_return.


DATA:gc_matnr TYPE ekpo-matnr,
it_list TYPE TABLE OF abaplist,
wa_list LIKE LINE OF it_list.

RANGES: r_matnr FOR ekpo-matnr.


SELECT-OPTIONS: s_matnr FOR gc_matnr.

SUBMIT rm06em00
EXPORTING LIST TO MEMORY
WITH em_matnr IN s_matnr
WITH listu = 'ALLES'
AND RETURN.

CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = it_list
EXCEPTIONS
not_found = 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.
ELSE.
LOOP AT it_list INTO wa_list.
WRITE wa_list-rfcrecord.
ENDLOOP.
ENDIF.


(0) 评论    (92) 引用   

BC425(Enhancements and Modifications)总结

BC425读过有年头了,不过一直没有总结出来。今天上午把大概比较重要的知识点总结出来,有很多是即使做过enhancement的人也不是很清楚的。具体图片请参考BC425.rar

Table Enhancement

l Append Structure

l Append structures are created for use with a specific table

l Multiple append structures can be used with a single table

l Append structures can be used just like any other structure

一个structure只能append给一个table,但是一个table可以append很多structure.

如果copy一个有append structuretable,那么append structure里的字段都将成为新表中的普通字段。

可以对poolclusterappend structure,但是如果表中有LCHR LRAW字段则不行。

Structurefield的名字用customer namespace(ZZ YY)防止SAP系统升级时产生冲突,SAP系统升级时,会自动保留append structure

l Customizing include

n Must be specified by the SAP developer

n Is created by the customer

Include可以同时插入到很多表中。命名规约为以CI_开头,确保不与SAP标准冲突。Include中的字段名字以ZZ YY开头。

Text Enhancements

l Data Element Keywords

l Documentation

Customer Exit

TCODE: CMOD SMOD(参考Tim的讲解)

l Function Module Exit

SAP标准程序用,用CALL CUSTOMER-FUNCTION来调用,而且后面只是一个号码,比如001.

系统自动调用EXIT_<Programe_name>_001这个函数。其中program name便是拥有function module exitSAP标准程序名。另外,这些function都是存在于X开头的function group中。Function中都有一个zx开头的include语句,为客户开发预留。

对于X function groupSAP也有一些规定:如果function group的程序名为SAPLXAAA,则全局数据存储在LXAAATOP中,所有的function module存储在LXAAAUXX中,每一个function module对应存储在LXAAAU01…XX中。Subroutine存储在LXAAAF01…LXAAAFXX中。Group中的include要么以LX开头,要么以ZX开头,我们只能编辑以ZX开头的。比如自己定义的TOP include ZXAAATOP用来保存全局数据。自己创建的其他Object:ZXAAAO01(PBO) ZXAAAI01(PAI)ZXAAAE01(ABAP Events)

l Menu Exit

Menu Exit允许将自定义的功能附着在SAP菜单之上。这些为客户预留的menu exitSAP中,FCode以‘+’开头,在激活project之前不会显示。Menu Exit一般都会有预留的function module exit与之配合一起工作。

l Screen Exit

Screen Exit允许我们在SAP预留的screen area中定义自己的subscreen。在系统程序中,调用screen exit的方法为:
PBO CALL CUSTOMER-SUBSCREEN <area> INCLUDING <X-function-pool> <screen_number>

PAI CALL CUSTOMER-SUBSCREEN <area>

我们要在相应的function group中创建PBO PAI相应的module.而系统程序主屏幕与subscreen调用顺序如下:

而使用screen exit的一个最大问题在于数据的交换。因为标准系统程序并不会知道用户自定义屏幕中会有什么字段,所以不会预定义全局变量给它。需要在PBO系统预留的function module exit中讲subscreen可能需要的当前数据传输给子屏幕。而子屏幕经过处理再通过在系统程序PAI中预留的function module exit传输回来。具体过程如下图:

l BTE

Business Transaction Events (BTE) are enhancements that were developed for the Financial Accounting (FI) component of R/3.

BTE是专门为FI准备的,在执行某些动作是触发。我应用不是特别多,有时间再仔细研究一下,写出来细节。

BTE调用的细节图如下:

BTE的一个特点就是可以有多个实现。多个被激活的实现在执行中被逐一调用

在程序找到一个BTE的方法为:在程序中搜索 OPEN_FI_PERFORM 以及在IMGFI下找到Use business transaction events子菜单。

BTEcustomer exit相比有如下不同:

BTE只提供源代码级别的exit,没有menu screenBTE可以重用,不是跨client的,并且可以过滤。

l BAdIs(Business Add-Ins)

关于BAdI tim有过不错的介绍。可以简单的认为是一个OO版本的enhancement,但是它有很多新的特性。比如BAdl可以指定过滤条件,可以重用,只有被筛选出来的BAdl才会被执行。

BAdl的执行序列如下图

BAdl的命名规约为:BAdlinterface IF_EX_<badi> ZIF_EX_<baid>或者自定义namespace/IF_EX_<badi>

实现的类为CL_IM_<badi> ZCL_IM_<baid>或者自定义namespace/CL_IM_<badi>


(0) 评论    (4) 引用   

[收藏]ALV Grid Demo(OO ALV)

http://www.abaptech.com/?p=357 翱翔云天写的例子。真是不错!!

 查看全文

(0) 评论    (24) 引用   

[收藏]关于日期 数字 单位等转换和check的函数

从翱翔云天处看到一个整理的列表,十分的好

http://www.abaptech.com/?p=347

我单独补充一个根据用户的parameter设置(SU01)来检查数字格式合法性的

CATS_NUMERIC_INPUT_CHECK 不过这个没有release


(0) 评论    (18) 引用   

[收藏]动态创建内表的示例程序

*&---------------------------------------------------------------------*
*& Report ZDAVID_DYNAMIC_TABLE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT zdavid_dynamic_table.


TABLES: vbak, mara, vbap.

TYPE-POOLS: slis.

**********
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa>,
<dyn_field>,
<dyn_table1> TYPE STANDARD TABLE,
<dyn_wa1>,
<dyn_field1>.


DATA: dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
ifc TYPE lvc_t_fcat,
xfc TYPE lvc_s_fcat,
dy_table1 TYPE REF TO data,
dy_line1 TYPE REF TO data.

DATA: BEGIN OF list_protype OCCURS 0,
extwg LIKE mara-extwg,
END OF list_protype.

DATA: show_protype LIKE list_protype OCCURS 0 WITH HEADER LINE.

DATA: l_title TYPE string.

CONSTANTS: tab_key TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
**********************
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat LIKE LINE OF it_fieldcat,
wa_layout TYPE slis_layout_alv,
it_extab TYPE slis_t_extab.
DATA: name(20).

DATA: BEGIN OF it_item OCCURS 0,
vkorg LIKE vbak-vkorg, "Sales organization
vtweg LIKE vbak-vtweg, "distribution channel
kunnr LIKE vbak-kunnr, "sold-to party
name1 LIKE kna1-name1, "Customer name
bstnk LIKE vbak-bstnk, "PO number
vbeln LIKE vbak-vbeln, "sales document
erdat LIKE vbak-erdat, "document date
extwg LIKE mara-extwg, "product type
posnr LIKE vbap-posnr, "order item
matnr LIKE vbap-matnr, "Material
kwmeng LIKE vbap-kwmeng, "Order Qty
vrkme LIKE vbap-vrkme, "Sales Unit
netwr LIKE vbap-netwr, "Order Net Value
waerk LIKE vbap-waerk, "Currency
za_kbetr LIKE konv-kbetr, "ZA01 %Discount
ra_kbetr LIKE konv-kbetr, "RA00 %Discount
za_kwert LIKE konv-kwert, "ZA01 discount amount
ra_kwert LIKE konv-kwert, "ZA01 discount amount
knumv LIKE vbak-knumv, "condition number
vbtyp LIKE vbak-vbtyp, "SO type
END OF it_item.

DATA: BEGIN OF it_output OCCURS 0,
vkorg(4) TYPE c, "Sales organization
vtweg(2), "distribution channel
kunnr(10), "sold-to party
name1(35), "Customer name
bstnk(20), "PO number
vbeln(10), "sales document
erdat(8), "document date
extwg(18), "product type
posnr(6), "order item
matnr(18), "Material
kwmeng(15), "Order Qty
vrkme(3), "Sales Unit
netwr(15), "Order Net Value
waerk(13), "Currency
za_kbetr(11), "ZA01 %Discount
ra_kbetr(11), "RA00 %Discount
za_kwert(13), "ZA01 discount amount
ra_kwert(13), "ZA01 discount amount
END OF it_output.

DATA: BEGIN OF it_op_sum OCCURS 0,
vkorg(4) TYPE c, "Sales organization
vtweg(2), "distribution channel
kunnr(10), "sold-to party
name1(35), "Customer name
bstnk(20), "PO number
vbeln(10), "sales document
erdat(8), "document date
extwg(18), "product type
kwmeng(15), "Order Qty
vrkme(3), "Sales Unit
netwr(15), "Order Net Value
waerk(13), "Currency
za_kwert(13), "ZA01 discount amount
ra_kwert(13), "ZA01 discount amount
END OF it_op_sum.


TYPES: BEGIN OF ty_sum,
vkorg LIKE vbak-vkorg, "Sales organization
vtweg LIKE vbak-vtweg, "distribution channel
kunnr LIKE vbak-kunnr, "sold-to party
name1 LIKE kna1-name1, "Customer name
bstnk LIKE vbak-bstnk, "PO number
* vbeln like vbak-vbeln, "sales document
erdat LIKE vbak-erdat, "document date
extwg LIKE mara-extwg, "product type
kwmeng LIKE vbap-kwmeng, "Order Qty
vrkme LIKE vbap-vrkme, "Sales Unit
netwr LIKE vbap-netwr, "Order Net Value
waerk LIKE vbap-waerk, "Currency
za_kwert LIKE konv-kwert, "ZA01 discount amount
ra_kwert LIKE konv-kwert, "ZA01 discount amount
END OF ty_sum.

DATA: BEGIN OF sel OCCURS 0,
knumv LIKE vbrk-knumv,
posnn LIKE vbfa-posnn,
vbtyp_n LIKE vbfa-vbtyp_n,
END OF sel.

DATA: wa_sum TYPE ty_sum.

DATA: BEGIN OF it_protype OCCURS 0,
extwg LIKE mara-extwg,
netwr LIKE vbap-netwr,
END OF it_protype.

DATA: it_sum TYPE STANDARD TABLE
OF ty_sum INITIAL SIZE 10 WITH HEADER LINE.

SELECTION-SCREEN BEGIN OF BLOCK fname1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_vkorg FOR vbak-vkorg DEFAULT '4800' TO '4801',
s_vtweg FOR vbak-vtweg DEFAULT '31',
s_kunnr FOR vbak-kunnr,
s_erdat FOR vbak-erdat DEFAULT sy-datum,
s_extwg FOR mara-extwg.
SELECTION-SCREEN END OF BLOCK fname1.

SELECTION-SCREEN BEGIN OF BLOCK fname3 WITH FRAME TITLE text-003.
PARAMETER: rbank RADIOBUTTON GROUP rd1,
rintake RADIOBUTTON GROUP rd1 DEFAULT 'X',
rinvoice RADIOBUTTON GROUP rd1.
SELECTION-SCREEN END OF BLOCK fname3.

SELECTION-SCREEN BEGIN OF BLOCK fname4 WITH FRAME TITLE text-004.
PARAMETER: rabap RADIOBUTTON GROUP rd2 DEFAULT 'X',
rfile RADIOBUTTON GROUP rd2,
v_file LIKE rlgrap-filename
DEFAULT 'c:tempacdelco-statis.txt',
rserver RADIOBUTTON GROUP rd2,
v_server TYPE filepath-pathintern
DEFAULT '/icsdata/acdelco/acdelco-statis.txt'.
SELECTION-SCREEN END OF BLOCK fname4.

START-OF-SELECTION.

PERFORM selectdata.
PERFORM output.

*&---------------------------------------------------------------------*
*& Form selectdata
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM selectdata .
IF rbank = 'X'.
PERFORM selectrbank.
ELSEIF rintake = 'X'.
PERFORM selectintake.
ELSEIF rinvoice = 'X'.
PERFORM selectrinvoice.
ENDIF.
ENDFORM. " selectdata
*&---------------------------------------------------------------------*
*& Form output
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM output .
IF rabap = 'X'.
PERFORM outputabap.
ELSEIF rfile = 'X'.
PERFORM outputfile.
ELSEIF rserver = 'X'.
PERFORM outputfile.
ENDIF.

ENDFORM. " output
*&---------------------------------------------------------------------*
*& Form selectintake
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM selectintake .

* select basic order data
PERFORM selectbasic.


LOOP AT it_item.

* get customer name
SELECT SINGLE kna1~name1 FROM kna1
INTO it_item-name1
WHERE kna1~kunnr = it_item-kunnr.


* If SO is 'H'(return)
IF it_item-vbtyp = 'H'.
it_item-netwr = - it_item-netwr.
ENDIF.

MODIFY it_item.

MOVE-CORRESPONDING it_item TO wa_sum.
COLLECT wa_sum INTO it_sum.

ENDLOOP.

PERFORM dynamictable.

ENDFORM. " selectintake
*&---------------------------------------------------------------------*
*& Form selectrbank
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM selectrbank .
PERFORM selectbasic.
LOOP AT it_item.

* get customer name
SELECT SINGLE kna1~name1 FROM kna1
INTO it_item-name1
WHERE kna1~kunnr = it_item-kunnr.

* clear: it_item-kwmeng, it_item-netwr.
DATA: t_kwmeng LIKE it_item-kwmeng,
t_netwr LIKE it_item-netwr.

* When SD document category (VBAK~VBTYP) is 慍?(Order)
IF it_item-vbtyp = 'C'.
* If VBFA-VBTYP_N = M (invoice) ++
SELECT SUM( vbfa~rfmng ) SUM( vbrp~netwr )
FROM vbfa JOIN vbrp ON vbfa~vbeln = vbrp~vbeln AND vbfa~posnn =
vbrp~posnr
INTO (t_kwmeng, t_netwr)
WHERE vbfa~vbelv = it_item-vbeln
AND vbfa~posnv = it_item-posnr
AND vbfa~vbtyp_n = 'M'.
* If VBFA-VBTYP_N = N (invoice cancellation) --

it_item-kwmeng = it_item-kwmeng - t_kwmeng.
it_item-netwr = it_item-netwr - t_netwr.

CLEAR: t_kwmeng, t_netwr.

SELECT SUM( vbfa~rfmng ) SUM( vbrp~netwr )
FROM vbfa JOIN vbrp ON vbfa~vbeln = vbrp~vbeln AND vbfa~posnn =
vbrp~posnr
INTO (t_kwmeng, t_netwr)
WHERE vbfa~vbelv = it_item-vbeln
AND vbfa~posnv = it_item-posnr
AND vbfa~vbtyp_n = 'N'.

it_item-kwmeng = it_item-kwmeng + t_kwmeng.
it_item-netwr = it_item-netwr + t_netwr.

IF it_item-kwmeng = 0.
DELETE it_item.
CONTINUE.
ENDIF.

* When SD document category (VBAK~VBTYP) is H (Returns)
ELSEIF it_item-vbtyp = 'H'.
* If VBFA-VBTYP_N = O (Credit memo) ++
SELECT SUM( vbfa~rfmng ) SUM( vbrp~netwr )
FROM vbfa JOIN vbrp ON vbfa~vbeln = vbrp~vbeln AND vbfa~posnn =
vbrp~posnr
INTO (t_kwmeng, t_netwr)
WHERE vbfa~vbelv = it_item-vbeln
AND vbfa~posnv = it_item-posnr
AND vbfa~vbtyp_n = 'O'.

it_item-kwmeng = it_item-kwmeng - t_kwmeng.
it_item-netwr = it_item-netwr - t_netwr.


* If VBFA-VBTYP_N = S (Credit memo cancellation)
CLEAR: t_kwmeng, t_netwr.
SELECT SUM( vbfa~rfmng ) SUM( vbrp~netwr )
FROM vbfa JOIN vbrp ON vbfa~vbeln = vbrp~vbeln AND vbfa~posnn =
vbrp~posnr
INTO (t_kwmeng, t_netwr)
WHERE vbfa~vbelv = it_item-vbeln
AND vbfa~posnv = it_item-posnr
AND vbfa~vbtyp_n = 'S'.

it_item-kwmeng = it_item-kwmeng + t_kwmeng.
it_item-netwr = it_item-netwr + t_netwr.

IF it_item-kwmeng = 0.
DELETE it_item.
CONTINUE.
ENDIF.

ENDIF.

* If SO is 'H'(return)
IF it_item-vbtyp = 'H'.
it_item-netwr = - it_item-netwr.
ENDIF.


MODIFY it_item.

MOVE-CORRESPONDING it_item TO wa_sum.
COLLECT wa_sum INTO it_sum.


ENDLOOP.

PERFORM dynamictable.

ENDFORM. " selectrbank
*&---------------------------------------------------------------------*
*& Form selectrinvoice
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM selectrinvoice .
PERFORM selectbasic.

LOOP AT it_item.

* get customer name
SELECT SINGLE kna1~name1 FROM kna1
INTO it_item-name1
WHERE kna1~kunnr = it_item-kunnr.

CLEAR: it_item-kwmeng, it_item-netwr.
DATA: t_kwmeng LIKE it_item-kwmeng,
t_netwr LIKE it_item-netwr.

* When SD document category (VBAK~VBTYP) is 慍?(Order)
IF it_item-vbtyp = 'C'.
* If VBFA-VBTYP_N = M (invoice) ++
SELECT SUM( vbfa~rfmng ) SUM( vbrp~netwr )
FROM vbfa JOIN vbrp ON vbfa~vbeln = vbrp~vbeln AND vbfa~posnn =
vbrp~posnr
INTO (it_item-kwmeng, it_item-netwr)
WHERE vbfa~vbelv = it_item-vbeln
AND vbfa~posnv = it_item-posnr
AND vbfa~vbtyp_n = 'M'.
* If VBFA-VBTYP_N = N (invoice cancellation) --
CLEAR: t_kwmeng, t_netwr.

SELECT SUM( vbfa~rfmng ) SUM( vbrp~netwr )
FROM vbfa JOIN vbrp ON vbfa~vbeln = vbrp~vbeln AND vbfa~posnn =
vbrp~posnr
INTO (t_kwmeng, t_netwr)
WHERE vbfa~vbelv = it_item-vbeln
AND vbfa~posnv = it_item-posnr
AND vbfa~vbtyp_n = 'N'.

* M (invoice) - N (invoice cancellation)
it_item-kwmeng = it_item-kwmeng - t_kwmeng.
it_item-netwr = it_item-netwr - t_netwr.

IF it_item-kwmeng = 0.
DELETE it_item.
CONTINUE.
ENDIF.


* When SD document category (VBAK~VBTYP) is H (Returns)
ELSEIF it_item-vbtyp = 'H'.
* If VBFA-VBTYP_N = O (Credit memo) ++
SELECT SUM( vbfa~rfmng ) SUM( vbrp~netwr )
FROM vbfa JOIN vbrp ON vbfa~vbeln = vbrp~vbeln AND vbfa~posnn =
vbrp~posnr
INTO (it_item-kwmeng, it_item-netwr)
WHERE vbfa~vbelv = it_item-vbeln
AND vbfa~posnv = it_item-posnr
AND vbfa~vbtyp_n = 'O'.

* If VBFA-VBTYP_N = S (Credit memo cancellation)
CLEAR: t_kwmeng, t_netwr.
SELECT SUM( vbfa~rfmng ) SUM( vbrp~netwr )
FROM vbfa JOIN vbrp ON vbfa~vbeln = vbrp~vbeln AND vbfa~posnn =
vbrp~posnr
INTO (t_kwmeng, t_netwr)
WHERE vbfa~vbelv = it_item-vbeln
AND vbfa~posnv = it_item-posnr
AND vbfa~vbtyp_n = 'S'.

* O (Credit memo) - S (Credit memo cancellation)
it_item-kwmeng = it_item-kwmeng - t_kwmeng.
it_item-netwr = it_item-netwr - t_netwr.

IF it_item-kwmeng = 0.
DELETE it_item.
CONTINUE.
ENDIF.


ENDIF.

* If SO is 'H'(return)
IF it_item-vbtyp = 'H'.
it_item-netwr = - it_item-netwr.
ENDIF.


MODIFY it_item.

MOVE-CORRESPONDING it_item TO wa_sum.
COLLECT wa_sum INTO it_sum.
ENDLOOP.

PERFORM dynamictable.

ENDFORM. " selectrinvoice
*&---------------------------------------------------------------------*
*& Form selectbasic
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM selectbasic .

* select basic order data
SELECT vbak~kunnr vbap~kwmeng vbak~vbeln
vbap~posnr vbap~matnr mara~extwg vbap~netwr vbap~waerk vbak~vbtyp
FROM vbak JOIN vbap ON vbap~vbeln = vbak~vbeln JOIN mara ON vbap~matnr =
mara~matnr
INTO CORRESPONDING FIELDS OF TABLE it_item
WHERE vbak~vkorg NE '4802'
AND vbak~vkorg NE '4803'
AND ( vbak~vbtyp EQ 'C' OR vbak~vbtyp EQ 'H')
AND vbap~abgru = ''
AND vbak~vkorg IN s_vkorg
AND vbak~vtweg IN s_vtweg
AND vbak~kunnr IN s_kunnr
AND vbak~erdat IN s_erdat
AND mara~extwg IN s_extwg
AND vbap~abgru EQ ''
AND mara~extwg NE ''.


ENDFORM. " selectbasic
*&---------------------------------------------------------------------*
*& Form outputabap
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM outputabap .
DEFINE a_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = &1.
wa_fieldcat-seltext_l = &2.
* wa_fieldcat-just = 'C'.
* wa_fieldcat-outputlen = &3.
wa_fieldcat-key = &3.
append wa_fieldcat to it_fieldcat.
END-OF-DEFINITION.

a_fieldcat 'KUNNR' 'Sold-to Party' 'X'.
a_fieldcat 'NAME1' 'Name' ''.
a_fieldcat 'PERIOD' 'Period Required' ''.

* a_fieldcat 'ERDAT' 'Period Required' ''.
* a_fieldcat 'EXTWG' 'Product Type' ''.

DATA: name1(20),
count TYPE i.

LOOP AT list_protype .
count = count + 1.
CONCATENATE list_protype-extwg 'RMB' INTO name.

READ TABLE show_protype INDEX count.
CONCATENATE show_protype-extwg '(RMB)' INTO name1.
a_fieldcat name name1 ''.

CONCATENATE list_protype-extwg 'USD' INTO name.
CONCATENATE show_protype-extwg '(USD)' INTO name1.
a_fieldcat name name1 ''.

CONCATENATE list_protype-extwg 'EURO' INTO name.
CONCATENATE show_protype-extwg '(EURO)' INTO name1.
a_fieldcat name name1 ''.
ENDLOOP.

a_fieldcat 'TOTALRMB' 'Total(RMB)' ''.
a_fieldcat 'TOTALUSD' 'Total(USD)' ''.
a_fieldcat 'TOTALEURO' 'Total(EURO)' ''.

* if rbank = 'X'.
* a_fieldcat 'NETWR' 'Bank Net Value' ''.
* elseif rintake = 'X'.
* a_fieldcat 'NETWR' 'Order Net Value' ''.
* elseif rinvoice = 'X'.
* a_fieldcat 'NETWR' 'Invoiced Net Value' ''.
* endif.
*
* a_fieldcat 'WAERK' 'Currency' ''.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = wa_layout
it_fieldcat = it_fieldcat
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = <dyn_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. " outputabap
*&---------------------------------------------------------------------*
*& Form outputfile
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM outputfile .

*loop at show_protype.
* concaterate
*endloop.


******* print head **********
CLEAR xfc.
REFRESH ifc.

xfc-fieldname = 'kunnr'.
xfc-datatype = 'CHAR'.
xfc-intlen = '13'.
APPEND xfc TO ifc.
xfc-fieldname = 'name1'.
xfc-datatype = 'CHAR'.
xfc-intlen = '35'.
APPEND xfc TO ifc.
xfc-fieldname = 'period'.
xfc-datatype = 'CHAR'.
xfc-intlen = '25'.
APPEND xfc TO ifc.

LOOP AT list_protype.


REPLACE '/' WITH '' INTO list_protype-extwg.
REPLACE '-' WITH '' INTO list_protype-extwg.
CONDENSE list_protype-extwg NO-GAPS.

CONCATENATE list_protype-extwg 'RMB' INTO name.
xfc-fieldname = name.
xfc-datatype = 'CHAR'.
xfc-intlen = 18.
* xfc-decimals = 2.
APPEND xfc TO ifc.

CONCATENATE list_protype-extwg 'USD' INTO name.

xfc-fieldname = name.
xfc-datatype = 'CHAR'.
xfc-intlen = 18.
* xfc-decimals = 2.
APPEND xfc TO ifc.

CONCATENATE list_protype-extwg 'EURO' INTO name.
xfc-fieldname = name.
xfc-datatype = 'CHAR'.
xfc-intlen = 18.
* xfc-decimals = 2.
APPEND xfc TO ifc.

MODIFY list_protype.

ENDLOOP.

** total ****

xfc-fieldname = 'TotalRMB'.
xfc-datatype = 'CHAR'.
xfc-intlen = 18.
* xfc-decimals = 2.
APPEND xfc TO ifc.

xfc-fieldname = 'TotalUSD'.
xfc-datatype = 'CHAR'.
xfc-intlen = 18.
* xfc-decimals = 2.
APPEND xfc TO ifc.

xfc-fieldname = 'TotalEURO'.
xfc-datatype = 'CHAR'.
xfc-intlen = 18.
* xfc-decimals = 2.
APPEND xfc TO ifc.

** total ****

CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table1.

ASSIGN dy_table1->* TO <dyn_table1>.

CREATE DATA dy_line LIKE LINE OF <dyn_table1>.

ASSIGN dy_line->* TO <dyn_wa1>.


DATA: count TYPE i.
count = 1.

ASSIGN COMPONENT count OF STRUCTURE <dyn_wa1> TO <dyn_field1>.
<dyn_field1> = 'Sold-to Party'.
count = count + 1.

ASSIGN COMPONENT count OF STRUCTURE <dyn_wa1> TO <dyn_field1>.
<dyn_field1> = 'Name'.
count = count + 1.

ASSIGN COMPONENT count OF STRUCTURE <dyn_wa1> TO <dyn_field1>.
<dyn_field1> = 'Period Required'.
count = count + 1.


LOOP AT show_protype .
ASSIGN COMPONENT count OF STRUCTURE <dyn_wa1> TO <dyn_field1>.
CONCATENATE show_protype-extwg '(RMB)' INTO <dyn_field1>.
count = count + 1.
ASSIGN COMPONENT count OF STRUCTURE <dyn_wa1> TO <dyn_field1>.
CONCATENATE show_protype-extwg '(USD)' INTO <dyn_field1>.
count = count + 1.
ASSIGN COMPONENT count OF STRUCTURE <dyn_wa1> TO <dyn_field1>.
CONCATENATE show_protype-extwg '(EURO)' INTO <dyn_field1>.
count = count + 1.

ENDLOOP.

ASSIGN COMPONENT count OF STRUCTURE <dyn_wa1> TO <dyn_field1>.
<dyn_field1> = 'Total(RMB)'.
count = count + 1.
ASSIGN COMPONENT count OF STRUCTURE <dyn_wa1> TO <dyn_field1>.
<dyn_field1> = 'Total(USD)'.
count = count + 1.
ASSIGN COMPONENT count OF STRUCTURE <dyn_wa1> TO <dyn_field1>.
<dyn_field1> = 'Total(EURO)'.
count = count + 1.


APPEND <dyn_wa1> TO <dyn_table1>.

LOOP AT <dyn_table> INTO <dyn_wa>.
MOVE-CORRESPONDING <dyn_wa> TO <dyn_wa1>.
APPEND <dyn_wa1> TO <dyn_table1>.
ENDLOOP.


* a_fieldcat 'TOTALRMB' 'Total(RMB)' ''.
* a_fieldcat 'TOTALUSD' 'Total(USD)' ''.
* a_fieldcat 'TOTALEURO' 'Total(EURO)' ''.

******* print head **********

IF rserver = ''.
CALL FUNCTION 'Z_UT_DOWNLOAD'
EXPORTING
i_path_file = v_file
i_local_pc = 'X'
i_fileformat = 'TAB'
* I_DELIMITER =
* IT_FIELD_CATALOG =
TABLES
it_input = <dyn_table1>
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_WRITE_ERROR = 2
* INVALID_FILESIZE = 3
* INVALID_TYPE = 4
* NO_BATCH = 5
* UNKNOWN_ERROR = 6
* INVALID_TABLE_WIDTH = 7
* GUI_REFUSE_FILETRANSFER = 8
* CUSTOMER_ERROR = 9
* DATASET_NO_AUTHORITY = 10
* DATASET_CANT_OPEN = 11
* DATASET_CANT_CLOSE = 12
* DATASET_NO_PIPE = 13
* DATASET_READ_ERROR = 14
* DATASET_TOO_MANY_FILES = 15
* DATASET_WRITE_ERROR = 16
* EXPORT_DATASET_CANNOT_OPEN = 17
* EXPORT_DATASET_WRITE_ERROR = 18
* OPEN_DATASET_NO_AUTHORITY = 19
* OPEN_PIPE_NO_AUTHORITY = 20
* USER_DEFINED_DELIMITER_MISSING = 21
* DELIMITER_NOT_IDENTIFIED = 22
* INCONSISTENT_FIELD_CATALOG = 23
* OTHERS = 24
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF sy-subrc = 0.
MESSAGE s999(fr) WITH 'Downloaded succesfully'.
ENDIF.

ELSE.
CALL FUNCTION 'Z_UT_DOWNLOAD'
EXPORTING
i_path_file = v_server
* I_LOCAL_PC = 'X'
i_fileformat = 'TAB'
* I_DELIMITER =
* IT_FIELD_CATALOG =
TABLES
it_input = <dyn_table1>
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_WRITE_ERROR = 2
* INVALID_FILESIZE = 3
* INVALID_TYPE = 4
* NO_BATCH = 5
* UNKNOWN_ERROR = 6
* INVALID_TABLE_WIDTH = 7
* GUI_REFUSE_FILETRANSFER = 8
* CUSTOMER_ERROR = 9
* DATASET_NO_AUTHORITY = 10
* DATASET_CANT_OPEN = 11
* DATASET_CANT_CLOSE = 12
* DATASET_NO_PIPE = 13
* DATASET_READ_ERROR = 14
* DATASET_TOO_MANY_FILES = 15
* DATASET_WRITE_ERROR = 16
* EXPORT_DATASET_CANNOT_OPEN = 17
* EXPORT_DATASET_WRITE_ERROR = 18
* OPEN_DATASET_NO_AUTHORITY = 19
* OPEN_PIPE_NO_AUTHORITY = 20
* USER_DEFINED_DELIMITER_MISSING = 21
* DELIMITER_NOT_IDENTIFIED = 22
* INCONSISTENT_FIELD_CATALOG = 23
* OTHERS = 24
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

IF sy-subrc = 0.
MESSAGE s999(fr) WITH 'Downloaded succesfully'.
ENDIF.

ENDIF.

ENDFORM. " outputfile

*&--------------------------------------------------------------------*
*& Form dynamictable
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM dynamictable.
LOOP AT it_sum.
MOVE-CORRESPONDING it_sum TO it_protype.
APPEND it_protype.
MOVE-CORRESPONDING it_sum TO list_protype.
APPEND list_protype.
ENDLOOP.

DATA period(25) TYPE c.

READ TABLE s_erdat INDEX 1.
CONCATENATE s_erdat-low '~' s_erdat-high INTO period.


SORT list_protype BY extwg.
DELETE ADJACENT DUPLICATES FROM list_protype.

*************** sold to party, name **********
xfc-fieldname = 'kunnr'.
xfc-datatype = 'CHAR'.
xfc-intlen = '10'.
APPEND xfc TO ifc.
xfc-fieldname = 'name1'.
xfc-datatype = 'CHAR'.
xfc-intlen = '35'.
APPEND xfc TO ifc.
xfc-fieldname = 'period'.
xfc-datatype = 'CHAR'.
xfc-intlen = '25'.
APPEND xfc TO ifc.

LOOP AT list_protype.
MOVE list_protype TO show_protype.
APPEND show_protype.

REPLACE '/' WITH '' INTO list_protype-extwg.
REPLACE '-' WITH '' INTO list_protype-extwg.
CONDENSE list_protype-extwg NO-GAPS.

CONCATENATE list_protype-extwg 'RMB' INTO name.
xfc-fieldname = name.
xfc-datatype = 'CURR'.
xfc-intlen = 15.
xfc-decimals = 2.
APPEND xfc TO ifc.

CONCATENATE list_protype-extwg 'USD' INTO name.

xfc-fieldname = name.
xfc-datatype = 'CURR'.
xfc-intlen = 15.
xfc-decimals = 2.
APPEND xfc TO ifc.

CONCATENATE list_protype-extwg 'EURO' INTO name.
xfc-fieldname = name.
xfc-datatype = 'CURR'.
xfc-intlen = 15.
xfc-decimals = 2.
APPEND xfc TO ifc.

MODIFY list_protype.

ENDLOOP.

** total ****

xfc-fieldname = 'TotalRMB'.
xfc-datatype = 'CURR'.
xfc-intlen = 15.
xfc-decimals = 2.
APPEND xfc TO ifc.

xfc-fieldname = 'TotalUSD'.
xfc-datatype = 'CURR'.
xfc-intlen = 15.
xfc-decimals = 2.
APPEND xfc TO ifc.

xfc-fieldname = 'TotalEURO'.
xfc-datatype = 'CURR'.
xfc-intlen = 15.
xfc-decimals = 2.
APPEND xfc TO ifc.

** total ****

CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.

ASSIGN dy_table->* TO <dyn_table>.

CREATE DATA dy_line LIKE LINE OF <dyn_table>.

ASSIGN dy_line->* TO <dyn_wa>.

SORT it_sum BY kunnr.


************ period time***********
DATA: sumrmb LIKE it_sum-netwr,
sumusd LIKE it_sum-netwr,
sumeuro LIKE it_sum-netwr,
isfirst.

LOOP AT it_sum.

AT NEW kunnr.
isfirst = ''.
AT FIRST.
isfirst = 'X'.
ENDAT.

IF isfirst <> 'X'.
APPEND <dyn_wa> TO <dyn_table>.
CLEAR: <dyn_wa>, sumrmb, sumusd, sumeuro.
ENDIF.
ENDAT.

ASSIGN COMPONENT 1 OF STRUCTURE <dyn_wa> TO <dyn_field>.
<dyn_field> = it_sum-kunnr.
ASSIGN COMPONENT 2 OF STRUCTURE <dyn_wa> TO <dyn_field>.
<dyn_field> = it_sum-name1.

ASSIGN COMPONENT 3 OF STRUCTURE <dyn_wa> TO <dyn_field>.
<dyn_field> = period.

REPLACE '/' WITH '' INTO it_sum-extwg.
REPLACE '-' WITH '' INTO it_sum-extwg.
CONDENSE it_sum-extwg NO-GAPS.

CONCATENATE it_sum-extwg it_sum-waerk INTO name.
ASSIGN COMPONENT name OF STRUCTURE <dyn_wa> TO <dyn_field>.
<dyn_field> = it_sum-netwr.

IF it_sum-waerk = 'RMB'.
sumrmb = sumrmb + it_sum-netwr.
ELSEIF it_sum-waerk = 'USD'.
sumusd = sumusd + it_sum-netwr.
ELSEIF it_sum-waerk = 'EURO'.
sumeuro = sumeuro + it_sum-netwr.
ENDIF.

ASSIGN COMPONENT 'TOTALRMB' OF STRUCTURE <dyn_wa> TO <dyn_field>.
<dyn_field> = sumrmb.
ASSIGN COMPONENT 'TOTALUSD' OF STRUCTURE <dyn_wa> TO <dyn_field>.
<dyn_field> = sumusd.
ASSIGN COMPONENT 'TOTALEURO' OF STRUCTURE <dyn_wa> TO <dyn_field>.
<dyn_field> = sumeuro.


AT LAST.
APPEND <dyn_wa> TO <dyn_table>.
CLEAR: <dyn_wa>, sumrmb, sumusd, sumeuro.
ENDAT.

ENDLOOP.

ENDFORM. "dynamictable

---------------------------------------------------------------------------------------------------------

*&---------------------------------------------------------------------*
*& Report ZDAVID_DYNAMIC_TABLE_2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT zdavid_dynamic_table_2.

TYPE-POOLS : abap.
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa>,
<dyn_field>.

DATA: dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
xfc TYPE lvc_s_fcat,
ifc TYPE lvc_t_fcat.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_table(30) TYPE c DEFAULT 'T001'.
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.

PERFORM get_structure.

PERFORM create_dynamic_itab.
**********Creates a dyanamic internal table**********
PERFORM get_data.

PERFORM write_out.

*&--------------------------------------------------------------------*
*& Form get_structure
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM get_structure.

DATA : idetails TYPE abap_compdescr_tab,
xdetails TYPE abap_compdescr.
DATA : ref_table_des TYPE REF TO cl_abap_structdescr.

* DATA : ref_table_des TYPE REF TO "cl_abap_structdescr
* CL_ABAP_TABLEDESCR.

* Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
LOOP AT idetails INTO xdetails.
CLEAR xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc.
ENDLOOP.

* TYPES: BEGIN OF typ_01,
* clo1,
* clo2,
* END OF typ_01.
*
* DATA: it_01 TYPE TABLE OF typ_01.
* DATA: wa_01 TYPE typ_01.
* wa_01 = '11'.
* APPEND wa_01 TO it_01.
* ref_table_des ?=
* cl_abap_typedescr=>describe_by_data( it_01 ).


ENDFORM. "get_structure
*&--------------------------------------------------------------------*
*& Form create_dynamic_itab
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM create_dynamic_itab.
* Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
* Create dynamic work area and assign to FS
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ENDFORM. "create_dynamic_itab

*&--------------------------------------------------------------------*
*& Form get_data
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM get_data.
* Select Data from table.
SELECT * INTO TABLE <dyn_table>
FROM (p_table).
ENDFORM. "get_data
"get_data
*&--------------------------------------------------------------------*
*& Form write_out
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM write_out.
* Write out data from table.
LOOP AT <dyn_table> INTO <dyn_wa>.
DO.
ASSIGN COMPONENT sy-index
OF STRUCTURE <dyn_wa> TO <dyn_field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF sy-index = 1.
WRITE:/ <dyn_field>.
ELSE.
WRITE: <dyn_field>.
ENDIF.
ENDDO.
ENDLOOP.
ENDFORM. "write_out


(0) 评论    (91) 引用   

赋值语句的两种方式

我们赋值的时候可以 destination = source 比如 gc_d = gc_s 有时候可以看到等号前有个问好

gc_d ?= gc_s 这是因为gc_s不是一个静态类型,而是一个引用类型,而且gc_d的类型要比gc_s更加泛化一些。

更加详细内容,参见ABAP文档

Syntax
MOVE source {TO|?TO} destination.

destination {=|?=} source.


Effect
Both these statements assign the content of the operand source to the data object destination. The variants with the language element TO or the assignment operator = are valid for all assignments between operands that are not reference variables, and for assignments between reference variables for which the static type of source is more specific than or the same as the static type of destination(narrowing cast).

Variants with the language element ?TO or the assignment operator ?= (casting operator ) must be used if the source and destination are reference variables and the static type of source is more general than the static type of destination (widening cast). For assignments between operands that are not reference variables, use of the question mark ? is not permitted.

The data object destination can be any data object that can be listed at a write position, and the data object source can be a data object, a predefined function or a functional method (as of release 6.10). The data type of the data object destination must either be compatible with the data type of source, or it must be possible to convert the content of source into the data type of destination according to one of the conversion rules.


Notes
If source and/or destination are field symbols, then, as in all ABAP commands, the system works with the content of the data objects to which the field symbols point. The actual pointer content of a field symbol can only be changed using the statement ASSIGN or the addition ASSIGNING when processing internal tables (value semantics). If source and destination are reference variables, the reference contained in source is assigned to destination (reference semantics).

Strings and internal tables are addressed internally using references. When assignments are made between strings and between internal tables (as of release 6.10), only the reference is transferred, for performance reasons. After the assignment, the actual string or the actual table body of the source as well as the target object are addressed (sharing). When the object is accessed to change it, the sharing is canceled and a copy of the content is made. The sharing is displayed in the memory consumption display of the ABAP debugger and in the Memory Inspector tool (as of release 6.20).

Obsolete Form: MOVE PERCENTAGE


Exceptions
Catchable Exceptions

CX_SY_CONVERSION_NO_NUMBER

Cause: Operand cannot be interpreted as number
Runtime Error: CONVT_NO_NUMBER (catchable)

CX_SY_CONVERSION_OVERFLOW

Cause: Overflow with arithmetic operation (type P, with specified length)
Runtime Error: BCD_FIELD_OVERFLOW (catchable)

Cause: Operand too large or (intermediate) result too large
Runtime Error: CONVT_OVERFLOW (catchable)

CX_SY_MOVE_CAST_ERROR

Cause: Source or target variable are not reference variables
Runtime Error: MOVE_CAST_REF_ONLY

Non-Catchable Exceptions

Cause: Source field (type P) does not contain correct BCD format.
Runtime Error: BCD_BADDATA

Cause: Assignment for deep structures not permitted if these overlap.
Runtime Error: MOVE_COMPLEX_OVERLAP

Cause: Type conflict with the assignment between object references.
Runtime Error: MOVE_INTERFACE_NOT_SUPPORTED,
Runtime Error: MOVE_IREF_NOT_CONVERTIBLE,
Runtime Error: MOVE_IREF_TO_OREF,
Runtime Error: MOVE_OREF_NOT_CONVERTIBLE

Cause: Type conflict with the assignment between data references.
Runtime Error: MOVE_DREF_NOT_COMPATIBLE

Cause: Assignment between the types involved not supported.
Runtime Error: MOVE_NOT_SUPPORTED

Cause: Constants and literals must not be overwritten.
Runtime Error: MOVE_TO_LIT_NOTALLOWED

Cause: onstants and literals must not be overwritten.
Runtime Error: MOVE_TO_LIT_NOTALLOWED_NODATA

Cause: During a loop in an internal table, an attempt was made to overwrite a reference variable that is linked with the internal table by REFERENCE INTO.
Runtime Error: MOVE_TO_LOOP_REF


(2) 评论    (92) 引用   

[收藏]关于COMMIT和ROLLBACK语句的使用注意事项

作者:莫怀远 1. COMMIT WORK 语句执行许多与任务的同步执行有关的功能。 ROLLBACK WORK语句“取消”任务同步执行的所有请求。 COMMIT WORK 语句进行下列处理: • 执行所有由PERFORM ON COMMIT 请求的FORM 例程。按优先级的升序执行这些例程,顺序由 PERFORM 语句的LEVEL 参数指定。 • 如果请求,触发所有更新任务功能模块。 • 如果请求,触发所有后台任务功能模块。 • 触发数据库提交(依次释放数据库锁定)。 • 清空反转日志。反转日志包含应用更改前的表格快照。执行反转时,该快照用来将表格复位到原值。 • 关闭所有打开的数据库光标。 • 将所有TEMSE 对象写入永久性文件或数据库。 TEMSE文件是由于性能原因在执行事务期间缓存的临时序列文件。TEMSE文件的示例有假脱机对象或作业日志。 • 将时间片计数器(用于访问工作进程)复位到0。系统中的时间片计数器限制工作进程中程序运行的时间量。如果程序常常超过时间片限制,则可以使用COMMIT WORK为程序获得更多时间。但是,要达此目的,必须很容易将处理分为更小单元(全部或没有操作)。然后可以在每个单元之后插入COMMIT WORK 语句。当然处理单元逻辑上必须独立,因为在发生错误时,不能取消前面的单元中所提交的更新。 ROLLBACK WORK“抛弃”当前事务的所有更新: • 抛弃所有以前用PERFORM ON COMMIT 登录的FORM例程 • 在更新任务队列中将所有以前请求的更新任务功能标记为错误 • 抛弃所有以前请求的后台任务功能 • 从缓冲存储中删除所有TEMSE对象(临时 连续文件,如假脱机对象和作业日志) • 触发数据库反转操作(依次释放所有数据库锁定) • 关闭所有打开的数据库光标 2. 以下情况需使用使用COMMIT和ROLLBACK语句。 1) 通过INSERT、UPDATE和MODIFY语句对数据库进行更新事务后。 2) 执行BAPI处理后。一般使用BAPI函数BAPI_TRANSACTION_COMMIT(内含COMMIT语句) 。 3. 如果要保证数据库中当前所作的更改立即被确认,那么就必须使用COMMIT WORK 语句结束LUW。COMMIT WORK 在程序代码中标记了 LUW(几个作业联系在一起形成作业的逻辑单元) 结束并启动更新任务。在COMMIT WORK 语句以后,对数据库所作的所有更改都不能再取消。但是,如果在LUW 中出现了错误,就必须取消已经执行的部分。这意味着当前没有任何插入的行能永久地保存在数据库中。要撤销当前LUW 对数据库的更改,请使用ROLLBACK WORK,它将取消前一次数据库提交后的所有更改。 4. COMMIT WORK [AND WAIT(同步)]. 如果使用AND WAIT选项,那么在程序继续执行以前,它要等到更新任务的结束。如果更新是成功的,SY-SUBRC 就设置为0。如果 SY-SUBRC 返回一个非零值,就没有成功的存储所作的更改。 ROLLBACK WORK. 如果对更改的取消是成功的,SY-SUBRC 就设置为0。如果 SY-SUBRC 返回一个非零值,就没有成功地取消所作的更改

(0) 评论    (95) 引用   

SAP modification基本概念之transport request

Original与Copies

一个object的original只能存在于一个系统之中,其它的统统叫做copy。比如SAP R/3系统中的Objects,最原始的original是存在于SAP本身,我们安装的只是original的copy版本。但是我们做的一些新的add-on开发,在开发机上却是original的,但是transport到QA机与生产机上的,就都是copy。

Corrections与Repair

对original进行的修改叫做correction。在transport request中的类别是Development/Corrections

所以我们看到在开发机上的add-on开发都属于这个类别。

对copy进行的修改叫做repair。对SAP object copy进行的修改,就叫做modification了。


(1) 评论    (46) 引用   

SAP upgrade中reset to original的注意事项

1. 在系统对于modification的调整中,reset to original对大部分object都是起作用的,除了BAdI和customer exit这种customer enhancement。这个是不能调整会系统原始状态的。

2. 对于使用了modification assistant的

如果还没有用SPAU进行调整(object前有交通灯icon),此刻使用reset to original只是将此刻的active版本作为original版本,也就是说object不会被更改,相反,升级中产生的modification会被删除。

如果已经进行了SPAU进行调整,则升级中产生的新的版本会在modification log中记录,此版本被认为是orginal版本,使用reset to original功能,以前的modification会被删除,upgrade过程中的版本会成为当前object.

3. 对于没有使用modification assistant的

不管有没有用SPAU进行调整过,当前的active版本都会被当作original版本使用

4.reset to original使用之后,SE95 SPAU都不会再显示这个Object,而且在以后的升级过程中,也不会再次出现在list中。


(0) 评论    (98) 引用   

[收藏]Demo on Enhancement FrameworkBy Jagadeshwar Gollap

Restrict users (sales persons) to view or change Sales order data - Using Enhancement framework:
Source Code Enhancement is one of the enhancement technologies available under Enhancement Framework. Implementing this technology is also called as Source Code Plug-In. Technically the source code plug-in implementations are stored in a separate include program and not as part of the original source program.
There are two types of Source Code enhancements possible.

    Implicit enhancement option
  • Explicit enhancement option

Example Scenario:
One sales person can’t see or change another sales person’s sales orders.
In my program, I have used following users.
Sales person1 (user 1): lz8xzf
Owner for Sales order no: 174.

Sales person2 (user 2): lzn4rm
Steps to Implement the Implicit enhancement option:
Step1:
Go to SE38 and Open include MV45AFZB

Step2:

In order to implement any of these Source code enhancements, you need to be in
‘change Enhancement mode’ (the spiral icon available in the editor).


Step3: Go to EDIT option in the menu and choose Enhancement Operations -> Show implicit Enhancement Options

All Implicit Enhancement option will be displayed. All yellow lines indicate Implicit Enhancement options. In ABAP programs, implicit enhancement options are predefined at the following places:

Begin/End of an include.

Begin/End of Method/Function Module/Form Routine

End of a structure

End of Private/Protected/Public Section of a local class


Step4: Place the cursor on the yellow line and choose
Enhancement implementation à Create.

Step5: Give Implementation name and then create.

Step6: Here Editor will be enabled to write the code. Write your own code save and activate it.

Step 7:
Once the development is completed you can test the scenario.
When Sales person (lzn4rm) tries to Open Sales order no 174, it gives error message ’Access Denied’.

Note: Sales order 174 is created by another sales person (lz8xzf).


(0) 评论    (91) 引用   

与variant有关的几个FUNCTION

  • VARI_USER_VARS_GET

Reads existing variable values

  • VARI_USER_VARS_SET

Changes existing variable values

  • RS_VARIANT_VALUES_TECH_DATA

Get variant data

  • RS_CHANGE_CREATED_VARIANT

Change variant data

  • VARI_USER_VARS_COPY
Copies variable values
  • VARI_USER_VARS_DELETE
Deletes variable values
  • VARI_USER_VARS_RENAME
Renames variable values
  • VARI_USER_VARS_DIALOG
Dialog for entering variable values

(0) 评论    (18) 引用   

[收藏]解决ALV的负数符号前显的问题

from http://blog.csdn.net/compassbutton/archive/2007/01/31/1499218.aspx

1、建立自定义函数
1.1 整数显示
FUNCTION CONVERSION_EXIT_Z0002_OUTPUT.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(INPUT)
*" EXPORTING
*" REFERENCE(OUTPUT)
*"----------------------------------------------------------------------
DATA: OUTPUT1(12) TYPE C,
OUTDATUM TYPE INT4.
IF INPUT <> SPACE.
OUTDATUM = INPUT.
if input > 0.
move OUTDATUM TO OUTPUT .
else.
OUTDATUM = OUTDATUM * ( -1 ).
move OUTDATUM TO OUTPUT1 .
CONCATENATE '-' output1 into output.
CONDENSE output NO-GAPS .
endif.
ELSE.
OUTPUT = SPACE.
ENDIF.
ENDFUNCTION.
1.2 浮点数显示
FUNCTION conversion_exit_zsign_output.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(INPUT)
*" EXPORTING
*" REFERENCE(OUTPUT)
*"----------------------------------------------------------------------

DATA: output1(19) TYPE c,
output2(19),
outdatum TYPE p DECIMALS 2.
IF not input is initial.
outdatum = input.
IF input > 0.
WRITE outdatum TO output1 ."RIGHT-JUSTIFIED .
CONCATENATE ' ' output1 INTO output1.
ELSE.
outdatum = outdatum * ( -1 ).
WRITE outdatum TO output1 ."RIGHT-JUSTIFIED.
CONCATENATE '-' output1 INTO output1.
ENDIF.
ELSE.
* output = '0.00'.
CLEAR output1.
ENDIF.
CONDENSE output1 NO-GAPS .
WRITE output1 TO output2 RIGHT-JUSTIFIED .
output = output2.
ENDFUNCTION.

2、设置ALV输出格式字段格式
clear ls_fcat.
ls_fcat-fieldname = 'INT4'.
ls_fcat-inttype = 'I'.
ls_fcat-intlen = 10.
ls_fcat-col_pos = l_lin.
ls_fcat-seltext_s = ls_fcat-fieldname.
ls_fcat-seltext_m = ls_fcat-fieldname.
ls_fcat-seltext_l = ls_fcat-fieldname.
ls_fcat-edit_mask = '==Z0002'.
append ls_fcat to ct_fcat.

3、调用函数就可达到负数符号前显的效果。
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = lt_fcat
tables
t_outtab = gt_outtab
exceptions
program_error = 1
others = 2.


(0) 评论    (94) 引用   

ALV GRID中改变的值更新到ALV内表中

首先编辑ALV的CALLER_EXIT事件,在call back的subroutine中做如下处理
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = W_ALV_GRID.

最后调用 W_ALV_GRID->CHECK_CHANGED_DATA( ).

ALV GRID中编辑的值就可以更新到ALV内表中了


(0) 评论    (90) 引用   

Change ALV subtotal text sample program

*&---------------------------------------------------------------------*
*& Report ZDAVID_ALV_SUBTOTAL_TXT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZDAVID_ALV_SUBTOTAL_TXT.
*&---------------------------------------------------------------------*
*& Table declaration
*&---------------------------------------------------------------------*
TABLES: ekko.
*&---------------------------------------------------------------------*
*& Type pool declaration
*&---------------------------------------------------------------------*
TYPE-POOLS: slis. " Type pool for ALV
*&---------------------------------------------------------------------*
*& Selection screen
*&---------------------------------------------------------------------*
SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.
*&---------------------------------------------------------------------*
*& Type declaration
*&---------------------------------------------------------------------*
* Type declaration for internal table to store EKPO data
TYPES: BEGIN OF x_data,
ebeln TYPE char30, " Document no.
ebelp TYPE ebelp, " Item no
matnr TYPE matnr, " Material no
matnr1 TYPE matnr, " Material no
werks TYPE werks_d, " Plant
werks1 TYPE werks_d, " Plant
ntgew TYPE entge, " Net weight
gewe TYPE egewe, " Unit of weight
END OF x_data.
*&---------------------------------------------------------------------*
*& Internal table declaration
*&---------------------------------------------------------------------*
DATA:
* Internal table to store EKPO data
i_ekpo TYPE STANDARD TABLE OF x_data INITIAL SIZE 0,
* Internal table for storing field catalog information
i_fieldcat TYPE slis_t_fieldcat_alv,
* Internal table for Top of Page info. in ALV Display
i_alv_top_of_page TYPE slis_t_listheader,
* Internal table for ALV Display events
i_events TYPE slis_t_event,
* Internal table for storing ALV sort information
i_sort TYPE slis_t_sortinfo_alv,
i_event TYPE slis_t_event.
*&---------------------------------------------------------------------*
*& Work area declaration
*&---------------------------------------------------------------------*
DATA:
wa_ekko TYPE x_data,
wa_layout TYPE slis_layout_alv,
wa_events TYPE slis_alv_event,
wa_sort TYPE slis_sortinfo_alv.
*&---------------------------------------------------------------------*
*& Constant declaration
*&---------------------------------------------------------------------*
CONSTANTS:
c_header TYPE char1
VALUE 'H', "Header in ALV
c_item TYPE char1
VALUE 'S'.
*&---------------------------------------------------------------------*
*& Start-of-selection event
*&---------------------------------------------------------------------*
START-OF-SELECTION.
* Select data from ekpo
SELECT ebeln " Doc no
ebelp " Item
matnr " Material
matnr " Material
werks " Plant
werks " Plant
ntgew " Quantity
gewei " Unit
FROM ekpo
INTO TABLE i_ekpo
WHERE ebeln IN s_ebeln
AND ntgew NE '0.00'. IF sy-subrc = 0.
SORT i_ekpo BY ebeln ebelp matnr .
ENDIF.
* To build the Page header
PERFORM sub_build_header.
* To prepare field catalog
PERFORM sub_field_catalog.
* Perform to populate the layout structure
PERFORM sub_populate_layout.
* Perform to populate the sort table.
PERFORM sub_populate_sort.
* Perform to populate ALV event
PERFORM sub_get_event.END-OF-SELECTION.
* Perform to display ALV report
PERFORM sub_alv_report_display.
*&---------------------------------------------------------------------*
*& Form sub_build_header
*&---------------------------------------------------------------------*
* To build the header
*----------------------------------------------------------------------*
* No Parameter
*----------------------------------------------------------------------*
FORM sub_build_header .
* Local data declaration
DATA: l_system TYPE char10 , "System id
l_r_line TYPE slis_listheader, "Hold list header
l_date TYPE char10, "Date
l_time TYPE char10, "Time
l_success_records TYPE i, "No of success records
l_title(300) TYPE c. " Title
* Title Display
l_r_line-typ = c_header. " header
l_title = 'Test report'(001).
l_r_line-info = l_title.
APPEND l_r_line TO i_alv_top_of_page.
CLEAR l_r_line.
* Run date Display
CLEAR l_date.
l_r_line-typ = c_item. " Item
WRITE: sy-datum TO l_date MM/DD/YYYY.
l_r_line-key = 'Run Date :'(002).
l_r_line-info = l_date.
APPEND l_r_line TO i_alv_top_of_page.
CLEAR: l_r_line,
l_date.ENDFORM. " sub_build_header
*&---------------------------------------------------------------------*
*& Form sub_field_catalog
*&---------------------------------------------------------------------*
* Build Field Catalog
*----------------------------------------------------------------------*
* No Parameter
*----------------------------------------------------------------------*
FORM sub_field_catalog .
* Build Field Catalog
PERFORM sub_fill_alv_field_catalog USING: '01' '01' 'EBELN' 'I_EKPO' 'L'
'Doc No'(003) ' ' ' ' ' ' ' ', '01' '02' 'EBELP' 'I_EKPO' 'L'
'Item No'(004) 'X' 'X' ' ' ' ', '01' '03' 'MATNR' 'I_EKPO' 'L'
'Material No'(005) 'X' 'X' ' ' ' ', '01' '03' 'MATNR1' 'I_EKPO' 'L'
'Material No'(005) ' ' ' ' ' ' ' ',
'01' '04' 'WERKS' 'I_EKPO' 'L'
'Plant'(006) 'X' 'X' ' ' ' ', '01' '04' 'WERKS1' 'I_EKPO' 'L'
'Plant'(006) ' ' ' ' ' ' ' ', '01' '05' 'NTGEW' 'I_EKPO' 'R'
'Net Weight'(007) ' ' ' ' 'GEWE' 'I_EKPO'.ENDFORM. " sub_field_catalog
*&---------------------------------------------------------------------*
*& Form sub_fill_alv_field_catalog
*&---------------------------------------------------------------------*
*& For building Field Catalog
*&---------------------------------------------------------------------*
*& p_rowpos Row position
*& p_colpos Col position
*& p_fldnam Fldname
*& p_tabnam Tabname
*& p_justif Justification
*& p_seltext Seltext
*& p_out no out
*& p_tech Technical field
*& p_qfield Quantity field
*& p_qtab Quantity table
*&---------------------------------------------------------------------*
FORM sub_fill_alv_field_catalog USING p_rowpos TYPE sycurow
p_colpos TYPE sycucol
p_fldnam TYPE fieldname
p_tabnam TYPE tabname
p_justif TYPE char1
p_seltext TYPE dd03p-scrtext_l
p_out TYPE char1
p_tech TYPE char1
p_qfield TYPE slis_fieldname
p_qtab TYPE slis_tabname.
* Local declaration for field catalog
DATA: wa_lfl_fcat TYPE slis_fieldcat_alv.
wa_lfl_fcat-row_pos = p_rowpos. "Row
wa_lfl_fcat-col_pos = p_colpos. "Column
wa_lfl_fcat-fieldname = p_fldnam. "Field Name
wa_lfl_fcat-tabname = p_tabnam. "Internal Table Name
wa_lfl_fcat-just = p_justif. "Screen Justified
wa_lfl_fcat-seltext_l = p_seltext. "Field Text
wa_lfl_fcat-no_out = p_out. "No output
wa_lfl_fcat-tech = p_tech. "Technical field
wa_lfl_fcat-qfieldname = p_qfield. "Quantity unit
wa_lfl_fcat-qtabname = p_qtab . "Quantity table
IF p_fldnam = 'NTGEW'.
wa_lfl_fcat-do_sum = 'X'.
ENDIF.
APPEND wa_lfl_fcat TO i_fieldcat.
CLEAR wa_lfl_fcat.
ENDFORM. " sub_fill_alv_field_catalog
*&---------------------------------------------------------------------*
*& Form sub_populate_layout
*&---------------------------------------------------------------------*
* Populate ALV layout
*----------------------------------------------------------------------*
* No Parameter
*----------------------------------------------------------------------*
FORM sub_populate_layout . CLEAR wa_layout.
wa_layout-colwidth_optimize = 'X'." Optimization of Col width
ENDFORM. " sub_populate_layout
*&---------------------------------------------------------------------*
*& Form sub_populate_sort
*&---------------------------------------------------------------------*
* Populate ALV sort table
*----------------------------------------------------------------------*
* No Parameter
*----------------------------------------------------------------------*
FORM sub_populate_sort .
* Sort on material
wa_sort-spos = '01' .
wa_sort-fieldname = 'MATNR'.
wa_sort-tabname = 'I_EKPO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.
* Sort on plant
wa_sort-spos = '02'.
wa_sort-fieldname = 'WERKS'.
wa_sort-tabname = 'I_EKPO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.
ENDFORM. " sub_populate_sort
*&---------------------------------------------------------------------*
*& Form sub_get_event
*&---------------------------------------------------------------------*
* Get ALV grid event and pass the form name to subtotal_text
* event
*----------------------------------------------------------------------*
* No Parameter
*----------------------------------------------------------------------*
FORM sub_get_event .
CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.
DATA: l_s_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 4
IMPORTING
et_events = i_event
EXCEPTIONS
list_type_wrong = 0
OTHERS = 0.
* Subtotal
READ TABLE i_event INTO l_s_event
WITH KEY name = slis_ev_subtotal_text.
IF sy-subrc = 0.
MOVE c_formname_subtotal_text TO l_s_event-form.
MODIFY i_event FROM l_s_event INDEX sy-tabix.
ENDIF.ENDFORM. " sub_get_event
*&---------------------------------------------------------------------*
*& Form sub_alv_report_display
*&---------------------------------------------------------------------*
* For ALV Report Display
*----------------------------------------------------------------------*
* No Parameter
*----------------------------------------------------------------------*
FORM sub_alv_report_display .
DATA: l_repid TYPE syrepid .
l_repid = sy-repid .
* This function module for displaying the ALV report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
i_callback_top_of_page = 'SUB_ALV_TOP_OF_PAGE'
is_layout = wa_layout
it_fieldcat = i_fieldcat
it_sort = i_sort
it_events = i_event
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = i_ekpo
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE i000 WITH 'Error in ALV report display'(055).
ENDIF.ENDFORM. " sub_alv_report_display*&---------------------------------------------------------------------*
* FORM sub_alv_top_of_page
*---------------------------------------------------------------------*
* Call ALV top of page
*---------------------------------------------------------------------*
* No parameter
*---------------------------------------------------------------------*
FORM sub_alv_top_of_page. "#EC CALLED* To write header for the ALV
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_alv_top_of_page.
ENDFORM. "alv_top_of_page
*&---------------------------------------------------------------------*
*& Form subtotal_text
*&---------------------------------------------------------------------*
* Build subtotal text
*----------------------------------------------------------------------*
* P_total Total
* p_subtot_text Subtotal text info
*----------------------------------------------------------------------*
FORM subtotal_text CHANGING
p_total TYPE any
p_subtot_text TYPE slis_subtot_text.
* Material level sub total
IF p_subtot_text-criteria = 'MATNR'.
p_subtot_text-display_text_for_subtotal
= 'Material level total'(009).
ENDIF.
* Plant level sub total
IF p_subtot_text-criteria = 'WERKS'.
p_subtot_text-display_text_for_subtotal = 'Plant level total'(010).
ENDIF.
ENDFORM. "subtotal_text


(0) 评论    (95) 引用   

隐藏标准选择屏幕的执行按钮

CONSTANTS cns_exec(4) TYPE c VALUE 'ONLI'.
DATA td_exclude TYPE TABLE OF sy-ucomm.

PARAMETER p_1 TYPE lifnr.

AT SELECTION-SCREEN OUTPUT.
APPEND cns_exec TO td_exclude.
CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
EXPORTING
p_status = sy-pfkey
TABLES
p_exclude = td_exclude.

(0) 评论    (105) 引用   

MM01跑BDC一个有意思的小地方

我们知道一般跑BDC用sy-subrc判断是否成功是不准确的。要用BDC的message table。
今天reivew一个物料主数据的interface程序,用得subrc,在我DEBUG的时候就出现了有意思的事情。这个MM01是写在一个subroutine里的,如果我直接F6,过掉这个subroutine没有任何问题,说明subrc为0。如果我F5跟了进去,CALL TRANSACTION之后,SUBRC是不等于0的,是1001.但是BDC MESSAGE是两条S型的。

除此以外,BDC程序的DEBUG还有很多奇怪的好玩的现象,比如无论返回的MESSAGE是否都是S型,数据都没有成功更新,只有将MODE改为一屏一屏跟进去才行。但是如果不DEBUG直接后台跑就不会有问题。呵呵~~~ BDC确实应该被BAPI替代掉。好多问题很诡异的。


(0) 评论    (94) 引用   

Convert Smartform to PDF 转化smartform到PDF格式

如果仅仅是自己想临时dowload某个smartform打印结果
1. Print the smartform to the spool.
2. Note the spool number.
3. Download a PDF file (Acrobat Reader) version of the spool by running Program RSTXPDFT4 and entering the
noted spool number.
如果有程序的需求,比如直接做成PDF格式发email之类的,就需要 OTF TO PDF function了 可以参考一下这封官方文档 还有sample code
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/62ae7fcd-0b01-0010-3e9d-a54f26944450

更多的信息https://www.sdn.sap.com/irj/sdn/thread?threadID=232171


(0) 评论    (89) 引用   

smartform的trace

有些时候smartform的form画得不对,在设计form layout的时候check是不出错的,但是一旦跑了function, exception就返回了。但是单单凭这个很难知道到底哪错了。
那么有一个有用的TCODE SMARTFORM_TRACE
switch on以后就会捕捉到smartform中报的具体的错误


(0) 评论    (99) 引用   

Download in Background in Excel Format

How to download the data in excel format directly while executing in background mode?
If you will execute it in bacground with ws_download or download, it will be aoutomatically cancel. so what is the procedure to do this. How is can directly read the spool from program?

Download from background is possible, if you could setup the environment

1. create a custom table first
Table : Y001
Displayed fields: 4 of 4 Fixed columns:

MANDT BNAME Y_SITE Y_PATH
010 <userid> <site> cd <novell_path>

2. rewrite ws_download to z_download (light modification required, see attachment)

3. ask your basis team to make a copy of command FTP and CHMOD to ZFTP and ZCHMOD resp., make the setting according to your environment.

    1  *-----------------------------------------------------------------------
    2  * Changed By : 
    3  * Changed On : 
    4  * Changed    : NOVELL directory path based on SAP login id.
    5  *-----------------------------------------------------------------------
    6  TABLES: Y001.                                            
    7
    8  CONSTANTS: C_PATH(14) VALUE '/home/ftpuser/'.
    9
   10  DATA: BEGIN OF C_TAB,
   11          X(1) TYPE X VALUE '09',
   12        END OF C_TAB.
   13
   14  DATA: BUFFER(8000),
   15        FIELDNAME_OFFSET TYPE I,
   16  *     FULLPATH(128),
   17        FULLPATH LIKE SXPGCOLIST-PARAMETERS,
   18  *     CMDFULLPATH(128),
   19        CMDFULLPATH LIKE SXPGCOLIST-PARAMETERS,
   20        CMD(40),
   21        IBTCXPM LIKE BTCXPM OCCURS 0.
   22
   23  FUNCTION Z_DOWNLOAD.
   24  *"----------------------------------------------------------------------
   25  *"*"Local interface:
   26  *"  IMPORTING
   27  *"     VALUE(FILENAME)
   28  *"     VALUE(LOCATION)
   29  *"  TABLES
   30  *"      DATA_TAB
   31  *"      FIELDNAMES OPTIONAL
   32  *"----------------------------------------------------------------------
   33
   34    DATA: WS_LINE TYPE I.
   35
   36    FIELD-SYMBOLS: <F>.
   37
   38    CHECK NOT FILENAME IS INITIAL.
   39
   40    CONCATENATE C_PATH FILENAME INTO FULLPATH.
   41    OPEN DATASET FULLPATH IN TEXT MODE FOR OUTPUT.
   42
   43    DESCRIBE TABLE FIELDNAMES LINES WS_LINE.
   44    IF WS_LINE NE 0.
   45      PERFORM FIELDNAMES_2_BUFFER TABLES FIELDNAMES CHANGING BUFFER.
   46      FIELDNAME_OFFSET = STRLEN( BUFFER ).
   47      TRANSFER BUFFER TO FULLPATH LENGTH FIELDNAME_OFFSET.
   48    ENDIF.
   49
   50    LOOP AT DATA_TAB.
   51      CLEAR BUFFER.
   52      CLEAR FIELDNAME_OFFSET.
   53      DO.
   54        ASSIGN COMPONENT SY-INDEX OF STRUCTURE DATA_TAB TO <F>.
   55        IF SY-SUBRC NE 0.  EXIT.  ENDIF.
   56        WRITE <F> TO BUFFER+FIELDNAME_OFFSET.
   57        CONDENSE BUFFER.
   58        FIELDNAME_OFFSET = STRLEN( BUFFER ).
   59        WRITE C_TAB TO BUFFER+FIELDNAME_OFFSET(1).
   60        ADD 1 TO FIELDNAME_OFFSET.
   61      ENDDO.
   62      TRANSFER BUFFER TO FULLPATH LENGTH FIELDNAME_OFFSET.
   63    ENDLOOP.
   64
   65    CLOSE DATASET FULLPATH.
   66
   67    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
   68         EXPORTING
   69              COMMANDNAME                   = 'ZCHMOD'
   70              ADDITIONAL_PARAMETERS         = FULLPATH
   71         TABLES
   72              EXEC_PROTOCOL                 = IBTCXPM
   73         EXCEPTIONS
   74              NO_PERMISSION                 = 1
   75              COMMAND_NOT_FOUND             = 2
   76              PARAMETERS_TOO_LONG           = 3
   77              SECURITY_RISK                 = 4
   78              WRONG_CHECK_CALL_INTERFACE    = 5
   79              PROGRAM_START_ERROR           = 6
   80              PROGRAM_TERMINATION_ERROR     = 7
   81              X_ERROR                       = 8
   82              PARAMETER_EXPECTED            = 9
   83              TOO_MANY_PARAMETERS           = 10
   84              ILLEGAL_COMMAND               = 11
   85              WRONG_ASYNCHRONOUS_PARAMETERS = 12
   86              CANT_ENQ_TBTCO_ENTRY          = 13
   87              JOBCOUNT_GENERATION_ERROR     = 14
   88              OTHERS                        = 15.
   89
   90    CONCATENATE C_PATH FILENAME '_cmd' INTO CMDFULLPATH.
   91    OPEN DATASET CMDFULLPATH IN TEXT MODE FOR OUTPUT.
   92    CASE LOCATION.     "location A, B, C, D on a network
   93      WHEN 'A  '.
   94  
   95        TRANSFER 'open xx.xxx.xx.xx' TO CMDFULLPATH.         
   96        TRANSFER 'user sapftp <pwd>' TO CMDFULLPATH.       
   97      WHEN 'B  '.                                            
   98        TRANSFER 'open xx.xxx.xx.xx' TO CMDFULLPATH.         
   99        TRANSFER 'user sapftp <pwd>' TO CMDFULLPATH.     
  100      when 'C  '.
  101        TRANSFER 'open xx.xxx.xx.xx' TO CMDFULLPATH.
  102        TRANSFER 'user sapftp <pwd>' TO CMDFULLPATH.
  103      when 'D  '.
  104        TRANSFER 'open xx.xxx.xx.xx' TO CMDFULLPATH.
  105        TRANSFER 'user sapftp <pwd>' TO CMDFULLPATH.
  106      WHEN OTHERS.
  107    ENDCASE.
  108 
  109 
  110 
  111 
  112  *start>
  113    CLEAR Y001.
  114    SELECT SINGLE Y_PATH INTO Y001-Y_PATH
  115                         FROM Y001 WHERE BNAME = SY-UNAME
  116                                     AND Y_SITE = LOCATION.   
  117    TRANSFER Y001-Y_PATH TO CMDFULLPATH.
  118  *<end
  119    CONCATENATE 'lcd' C_PATH INTO CMD SEPARATED BY SPACE.
  120    TRANSFER CMD TO CMDFULLPATH.
  121    CLEAR CMD.
  122    CONCATENATE 'put' FILENAME INTO CMD SEPARATED BY SPACE.
  123    TRANSFER CMD TO CMDFULLPATH.
  124    TRANSFER 'bye' TO CMDFULLPATH.
  125    CLOSE DATASET CMDFULLPATH.
  126
  127    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
  128         EXPORTING
  129              COMMANDNAME                   = 'ZCHMOD'
  130              ADDITIONAL_PARAMETERS         = CMDFULLPATH
  131         TABLES
  132              EXEC_PROTOCOL                 = IBTCXPM
  133         EXCEPTIONS
  134              NO_PERMISSION                 = 1
  135              COMMAND_NOT_FOUND             = 2
  136              PARAMETERS_TOO_LONG           = 3
  137              SECURITY_RISK                 = 4
  138              WRONG_CHECK_CALL_INTERFACE    = 5
  139              PROGRAM_START_ERROR           = 6
  140              PROGRAM_TERMINATION_ERROR     = 7
  141              X_ERROR                       = 8
  142              PARAMETER_EXPECTED            = 9
  143              TOO_MANY_PARAMETERS           = 10
  144              ILLEGAL_COMMAND               = 11
  145              WRONG_ASYNCHRONOUS_PARAMETERS = 12
  146              CANT_ENQ_TBTCO_ENTRY          = 13
  147              JOBCOUNT_GENERATION_ERROR     = 14
  148              OTHERS                        = 15.
  149
  150    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
  151         EXPORTING
  152              COMMANDNAME                   = 'ZFTP'
  153  **          commandname                   = 'ZFTP'
  154              ADDITIONAL_PARAMETERS         = CMDFULLPATH
  155         TABLES
  156              EXEC_PROTOCOL                 = IBTCXPM
  157         EXCEPTIONS
  158              NO_PERMISSION                 = 1
  159              COMMAND_NOT_FOUND             = 2
  160              PARAMETERS_TOO_LONG           = 3
  161              SECURITY_RISK                 = 4
  162              WRONG_CHECK_CALL_INTERFACE    = 5
  163              PROGRAM_START_ERROR           = 6
  164              PROGRAM_TERMINATION_ERROR     = 7
  165              X_ERROR                       = 8
  166              PARAMETER_EXPECTED            = 9
  167              TOO_MANY_PARAMETERS           = 10
  168              ILLEGAL_COMMAND               = 11
  169              WRONG_ASYNCHRONOUS_PARAMETERS = 12
  170              CANT_ENQ_TBTCO_ENTRY          = 13
  171              JOBCOUNT_GENERATION_ERROR     = 14
  172              OTHERS                        = 15.
  173
  174  ENDFUNCTION.
  175
  176  *---------------------------------------------------------------------*
  177  *       FORM FIELDNAMES_2_BUFFER                                      *
  178  *---------------------------------------------------------------------*
  179  *       ........                                                      *
  180  *---------------------------------------------------------------------*
  181  *  -->  FIELDNAMES                                                    *
  182  *  -->  BUFFER                                                        *
  183  *---------------------------------------------------------------------*
  184  FORM FIELDNAMES_2_BUFFER TABLES FIELDNAMES CHANGING BUFFER.
  185    CLEAR BUFFER.
  186    CLEAR FIELDNAME_OFFSET.
  187    LOOP AT FIELDNAMES.
  188      WRITE FIELDNAMES TO BUFFER+FIELDNAME_OFFSET.
  189      CONDENSE BUFFER.
  190      FIELDNAME_OFFSET = STRLEN( BUFFER ).
  191      WRITE C_TAB TO BUFFER+FIELDNAME_OFFSET(1).
  192      ADD 1 TO FIELDNAME_OFFSET.
  193    ENDLOOP.
  194    FIELDNAME_OFFSET = FIELDNAME_OFFSET - 1.
  195    IF FIELDNAME_OFFSET >= 0.
  196      WRITE SPACE TO BUFFER+FIELDNAME_OFFSET(1).
  197    ENDIF.
  198  ENDFORM.

(0) 评论    (38) 引用   

Control excel in SAP(border, color cell, etc)

http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm

Code:
REPORT ZSIRI NO STANDARD PAGE HEADING.
* this report demonstrates how to send some ABAP data to an
* EXCEL sheet using OLE automation.
INCLUDE OLE2INCL.
* handles for OLE objects
DATA: H_EXCEL TYPE OLE2_OBJECT, " Excel object
H_MAPL TYPE OLE2_OBJECT, " list of workbooks
H_MAP TYPE OLE2_OBJECT, " workbook
H_ZL TYPE OLE2_OBJECT, " cell
H_F TYPE OLE2_OBJECT. " font
TABLES: SPFLI.
DATA H TYPE I.
* table of flights
DATA: IT_SPFLI LIKE SPFLI OCCURS 10 WITH HEADER LINE.




*&---------------------------------------------------------------------*
*& Event START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
* read flights
SELECT * FROM SPFLI INTO TABLE IT_SPFLI UP TO 10 ROWS.
* display header
ULINE (61).
WRITE: / SY-VLINE NO-GAP,
(3) 'Flg'(001) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(4) 'Nr'(002) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(20) 'Von'(003) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(20) 'Nach'(004) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(8) 'Zeit'(005) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP.
ULINE /(61).
* display flights
LOOP AT IT_SPFLI.
WRITE: / SY-VLINE NO-GAP,
IT_SPFLI-CARRID COLOR COL_KEY NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CONNID COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CITYFROM COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CITYTO COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-DEPTIME COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP.
ENDLOOP.
ULINE /(61).
* tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
TEXT = TEXT-007
EXCEPTIONS
OTHERS = 1.
* start Excel
CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
* PERFORM ERR_HDL.

SET PROPERTY OF H_EXCEL 'Visible' = 1.
* CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:kis_excel.xls'
.

* PERFORM ERR_HDL.
* tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
TEXT = TEXT-008
EXCEPTIONS
OTHERS = 1.
* get list of workbooks, initially empty
CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
PERFORM ERR_HDL.
* add a new workbook
CALL METHOD OF H_MAPL 'Add' = H_MAP.
PERFORM ERR_HDL.
* tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
TEXT = TEXT-009
EXCEPTIONS
OTHERS = 1.
* output column headings to active Excel sheet
PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
PERFORM FILL_CELL USING 1 3 1 'Von'(003).
PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
LOOP AT IT_SPFLI.
* copy flights to active EXCEL sheet
H = SY-TABIX + 1.
PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
ENDLOOP.

* changes by Kishore - start
* CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
CALL METHOD OF H_EXCEL 'Worksheets' = H_MAPL." EXPORTING #1 = 2.

PERFORM ERR_HDL.
* add a new workbook
CALL METHOD OF H_MAPL 'Add' = H_MAP EXPORTING #1 = 2.
PERFORM ERR_HDL.
* tell user what is going on
SET PROPERTY OF H_MAP 'NAME' = 'COPY'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
* PERCENTAGE = 0
TEXT = TEXT-009
EXCEPTIONS
OTHERS = 1.
* output column headings to active Excel sheet
PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
PERFORM FILL_CELL USING 1 3 1 'Von'(003).
PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
LOOP AT IT_SPFLI.
* copy flights to active EXCEL sheet
H = SY-TABIX + 1.
PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
ENDLOOP.
* changes by Kishore - end
* disconnect from Excel
* CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'C:SKV.XLS'.

FREE OBJECT H_EXCEL.
PERFORM ERR_HDL.
*---------------------------------------------------------------------*
* FORM FILL_CELL *
*---------------------------------------------------------------------*
* sets cell at coordinates i,j to value val boldtype bold *
*---------------------------------------------------------------------*
FORM FILL_CELL USING I J BOLD VAL.
CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
PERFORM ERR_HDL.
SET PROPERTY OF H_ZL 'Value' = VAL .
PERFORM ERR_HDL.
GET PROPERTY OF H_ZL 'Font' = H_F.
PERFORM ERR_HDL.
SET PROPERTY OF H_F 'Bold' = BOLD .
PERFORM ERR_HDL.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ERR_HDL
*&---------------------------------------------------------------------*
* outputs OLE error if any *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ERR_HDL.
IF SY-SUBRC <> 0.
WRITE: / 'Fehler bei OLE-Automation:'(010), SY-SUBRC.
STOP.
ENDIF.
ENDFORM. " ERR_HDL


Please note that this example maybe slow at filling the excel table
(perhaps four fields per second on a 900 MHz machine - almost 30 seconds
for a short example).

To get the data on properties and methods - there is a bit of smoke and mirrors
going on here; they are EXCEL properties and methods, not sap ones - so you need
to look at excel help to determine how a particular function is structured. then
build the block in sap, as shown in the example.

If you only want to transfer the data to Excel like when you transfer the data from
ALV to Excel simply use the Function Modules:

XXL_SIMPLE_API

If you want more modifications when you transfer it to Excel use:

XXL_FULL_API

(0) 评论    (96) 引用   

debug调试backgrond跑的SAPScript

一个很棘手的问题,打印Handling Unit.但是这个不像Billing Doc是在前台跑的,这是一个后台作业,然后发送到SPOOL。这样的话,可怎么调试吧。
搜索了半天,google上还没啥好的方案,大家大部分也都只是知道如果调试一个Job而已。关键是这个后台作业根本不会在SM37里留下痕迹,就没法通过JDBG的OK CODE来调试。
最后,居然被我试了出来。方案如下。在code中设上断点。将SAPScript的form中active debug功能激活。
在保存了这个HU的output type之后要保存相关的delivery之前,/h,激活debug mode,然后保存。过不了几秒,background运行这个打印程序之时,就自动跳了进去。然后设置debug editor的update debugging,然后就慢慢跟吧,你会找到你那久违的断点的。:-)
相关的资料
http://jplamontre.free.fr/SAP/Debug%20background%20process.htm
http://www.sapdevelopment.co.uk/tips/debug/debug_backjob.htm
https://www.sdn.sap.com/irj/sdn/thread?threadID=574866&tstart=0
http://sap.ittoolbox.com/groups/technical-functional/sap-dev/how-to-debug-sapscript-for-f110-which-runs-in-background-799794

(0) 评论    (95) 引用   

SAPScript

倒霉的需求,有smartform不用,用SAPScript
Form画的少,好多问题都要现查。
这有个SAPScript编程指南的网络版。不错。
http://www.cnblogs.com/byfhd/archive/2007/07/05/806782.html
不过最好还是下载doc自己看。
另外有个有用的系统程序 RSTXSCRP
用来在不同client之间copy form的。

(0) 评论    (65) 引用   

有关READ_TEXT

关于READ_TEXT这个function总是很头疼。
如果知道想读什么text好办,直接前台跑T-CODE然后查看header信息就行了
(http://www.sapdevelopment.co.uk/sapscript/sapscript_texts.htm)
(http://fuller.mit.edu/SAPWebDocs/LongComment.html)
可是如果知道了ID和OBJECT怎么找到在哪个TCODE用前台维护呢?
直到目前为止,答案就是靠经验了。
通过OBJECT一般可以判断出来是哪个模块的哪个部分。之后就只能慢慢找了。
SE75这个TCODE我感觉用处不大。

不知道谁有什么其他好的办法没有?


(0) 评论    (16) 引用   

后台作业,Spool立即打印问题

今天在客户身边的同事,测试JOB作业打印report时发现report都还在spool中待机中,没有即时打印。 立即打印参数(http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba56d35c111d1829f0000e829fbfe/content.htm)已设,前台跑是没问题的。最后查出来,output device是非网络打印机。(SPAD)
有两条NOTE可以参考

Note 352739 - Dunning: Print immediately
Summary

Symptom
Even though the 'Print immediately' indicator is set for the dunning notice printout, immediate printing does not occur.
The following applies, irrespective of this correction: If the selected printer is a local printer, immediate printing is not possible from a background job.
For information about front-end printing, see Note 128105 also.
Note the difference between:
1. The 'Start immediately' indicator: this refers to the print program rather than the print output. The print program is either scheduled for a future point in time or started immediately.
2. The 'Print immediately' indicator in the spool control: If the indicator is set, the letters are printed immediately and a separate spool request is created for every letter. If the flag is not set, you have to start the print request, and only one spool request is created.

Note 128105 - Frontend printing (collective note)
Summary

Symptom
This note describes how frontend printing works.

Other terms
LOCL, frontend printing, PC print, control, control technology

Reason and Prerequisites
1. What does "Frontend printing" mean?
Frontend printing involves data, which needs to be printed, being sent using the GUI connection of the user to a printer that is installed on the frontend of the user. Usually, a default printer is involved.

Only a general printer definition is required in the backend system, since you are not required to define the names or IP addresses of the individual computers. You can use dynamic IP addresses (Dynamic Host Configuration Protocol) in frontend printing, unlike in network printing from the SAP System.

2. Availability
As of Basis Release 4. 6C, access method 'G' is available and replaces the previous method using access method 'F'. If you use access method 'G', frontend printing is also possible on non-Windows frontends. If you use a terminal server, no other settings are necessary. For more information, see Note 821519.

Access method 'F' is used in earlier releases (lower than 4.6C). As of Release 4.6C, access method 'F' is no longer developed, and no more corrections will be delivered.
Solution

1. Setting up frontend printing
To use access method 'G', see the prerequisites in Note 821519.

a) Definition of an output device
Define a general output device for frontend printing using transaction SPAD. You can use SAPWIN (or language-dependent SAPWIN versions) as a device type for Windows frontend computers. You can use any other device type, provided that all printers that you use can process the relevant format.
You cannot use SAPWIN on Non-Windows platforms, but you can use device type POST2 (for example), depending on the print administration setting.
On Windows platforms, enter __DEFAULT as the host printer, while on non-Windows platforms, enter a printer name that is standard on all frontend computers.

b) Authorizations
The following authorizations are required for frontend printing:
- Device authorization for the object S_SPO_DEV
(The following authorizations are only necessary for access method 'F':)
- Device authorization for device '%LOC' for the object S_SPO_DEV
- Authorization for the object S_RFC:
RFC_TYPE 'FUGR'
RFC_NAME 'LPRF'
ACTVT 16

c) Restrictions
Since frontend printing uses the local GUI connection, it is generally unsuitable for the output of large or particularly time-critical documents.

Frontend printing always requires an existing GUI connection. Therefore, you cannot use frontend printing to output the spool output of a background job.

Frontend printing is also impossible if you use RFC to go from your current mode into a process in which you first create the output request.

To print using the Windows Terminal Server (WTS), see Note 150533 also.

For further information about frontend printing using the SAPGUI for HTML, see Notes 351230 and 7721683.


(0) 评论    (45) 引用   

FOR ALL ENTRIES的效率问题

今天与jgtang82讨论FOR ALL ENTRIES与JOIN问题
SAP的数据字典对FOR ALL ENTRIES的封装也并不那么聪明。
关于效率问题,恰好有个不错的文章
记下来,以后可以备考
FOR ALL ENTRIES vs DB2 JOIN
http://blogs.ittoolbox.com/sap/db2/archives/for-all-entries-vs-db2-join-8912

All abap programers and most of the dba's that support abap programmers are familiar with the abap clause "for all entries". Most of the web pages I visited recently, discuss 3 major drawbacks of the "for all entries" clause:

1. duplicate rows are automatically removed
2. if the itab used in the clause is empty , all the rows in the source table will be selected .
3. performance degradation when using the clause on big tables.

In this post I'd like to shed some light on the third issue. Specifically i'll discuss the use of the "for all entries" clause as a means to join tables in the abap code instead of in db2.

Say for example you have the following abap code:
Select * from mara
For all entries in itab
Where matnr = itab-matnr.

If the actual source of the material list (represented here by itab) is actually another database table, like:
select matnr from mseg
into corresponding fields of table itab
where ?

Then you could have used one sql statement that joins both tables.
Select t1.*
From mara t1, mseg t2
Where t1.matnr = t2.matnr
And T2?.

So what are the drawbacks of using the "for all entires" instead of a join ?

At run time , in order to fulfill the "for all entries " request, the abap engine will generate several sql statements (for detailed information on this refer to note 48230). Regardless of which method the engine uses (union all, "or" or "in" predicates) If the itab is bigger then a few records, the abap engine will break the itab into parts, and rerun an sql statement several times in a loop. This rerun of the same sql statement , each time with different host values, is a source of resource waste because it may lead to re-reading of data pages.
returing to the above example , lets say that our itab contains 500 records and that the abap engine will be forced to run the following sql statement 50 times with a list of 10 values each time.
Select * from mara
Where matnr in ( ...)

Db2 will be able to perform this sql statement cheaply all 50 times, using one of sap standard indexes that contain the matnr column. But in actuality, if you consider the wider picture (all 50 executions of the statement), you will see that some of the data pages, especially the root and middle-tire index pages have been re-read each execution.

Even though db2 has mechanisms like buffer pools and sequential detection to try to minimize the i/o cost of such cases, those mechanisms can only minimize the actual i/o operations , not the cpu cost of re-reading them once they are in memory. Had you coded the join, db2 would have known that you actually need 500 rows from mara, it would have been able to use other access methods, and potentially consume less getpages i/o and cpu.

In other words , when you use the "for all entries " clause instead of coding a join , you are depriving the database of important information needed to select the best access path for your application. Moreover, you are depriving your DBA of the same vital information. When the DBA monitors & tunes the system, he (or she) is less likely to recognize this kind of resource waste. The DBA will see a simple statement that uses an index , he is less likely to realize that this statement is executed in a loop unnecessarily.

In conclusion I suggest to "think twice" before using the "for all entries" clause and to evaluate the use of database views as a means to:
a. simplify sql
b. simplify abap code
c. get around open sql limitations.

Omer Brandis
DB2 DBA & SAP Basis professional (and all around nice guy)
omerb@srl.co.il

另外,附上NOTE 48230
Summary

Symptom
Performance problems with the open SQL statement "SELECT ... FOR ALL ENTRIES ...".

Other terms
FOR_ALL_ENTRIES

Reason and Prerequisites
The open SQL statement "SELECT ... FOR ALL ENTRIES ..." is an ABAP-specific enhancement of the SQL standard. This variant of the SELECT statement allows the ABAP programmer to join an internal program table with one or several database tables. (For a detailed description of that statement type please refer to the corresponding ABAP documentation.)
Since there is no analogous statement in the SQL standard, the open SQL statement has to be mapped from the database interface of the ABAP environment to one or several semantically equivalent SELECT statements which can be processed by the DB platform. Several profile parameters allow a definition of how the database interface should carry out this mapping with regard to the database. This note describes the parameters that can be used to control the "SELECT ... FOR ALL ENTRIES" statement and their effect.

Solution
The parameters mentioned in this note have considerable effects on most of the critical database commands and influence the performance of the whole system to a great extent. For this reason, before changing the parameters described in this note, a detailed problem analysis by experienced SAP consultants or the support team is required. Please note in particular that changing the parameters may often solve a local performance problem but it may also cause a still bigger problem to occur at another place. For this reason, prior to changing the profile parameters - which has a global effect on all statements - you should check first whether the performance problem might be caused by one or two positions in the corresponding application which can be corrected by a local change of the critical SQL statements.

The following profile parameters are available:

rsdb/prefer_join (ab Release 7.0)
If you set this parameter to "1" the SELECT ... FOR ALL ENTRIES is implemented using a join. Note that this variant is only supported by the DB6 (DB2 UDB) and MS SQL Server database platforms.

rsdb/prefer_union_all
You can override this parameter using rsdb/prefer_join = 1. The following remarks relate to rsdb/prefer_join = 0.

Setting this parameter to "1" generates a linking of entire statements with UNION; setting it to "0" generates an OR link of conditions in the WHERE clause. Each of the linked partial statements/conditions represents an entry of the input table [itab].

For Example:
The open SQL statement

SELECT ... FOR ALL ENTRIES IN itab WHERE f = itab-f.

is mapped to an SQL statement which is consistent with the standard:

rsdb/prefer_union_all = 0
=>
SELECT ... WHERE f = itab[1]-f
OR f = itab[2]-f
...
OR f = itab[N]-f

rsdb/prefer_union_all = 1
=>
SELECT ... WHERE f = itab[1]-f
UNION ALL SELECT ... WHERE f = itab[2]-f
....
UNION ALL SELECT ... WHERE f = itab[N]-f

Where N is the number of rows in itab, and itab[i]-f is the value of
field f in the i-th table row.

rsdb/prefer_in_itab_opt
If this parameter is set to "1", a statement where only one field in the WHERE clause depends on the converted internal table is reflected by a statement with an IN clause. However, this is only possible if the field reference and the WHERE condition are simple enough: in essential the field reference must be a not negated EQ condition.

For Example:
If parameter rsdb/prefer_in_itab_opt is set to "1", the open SQL

SELECT ... FOR ALL ENTRIES IN itab WHERE f = itab-f.

is mapped to the following SQL statement:

SELECT ... WHERE f IN (itab[1]-f, itab[2]-f, ..., itab[N]-f)

rsdb/max_blocking_factor
This parameter specifies an upper limit for the number of entries taken in from [itab] to be processed in one statement. This means that if the internal table specified in the FOR ALL ENTRIES clause contains more than rsdb/max_blocking_factor rows, the open SQL statement is split into several statements for the database the results of which are collected in the DB interface and then returned as an overall result to the ABAP program. For an internal table with N rows

N / "rsdb/max_blocking_factor" + 1

individual SELECT statements are issued for the database. However, this parameter has no effect on the translation to IN (...) (for prefer_in_itab_opt).

Additionally the technical maximum blocking factor is calculated for each statement, so no limits of the database system are exceeded. If the limit of the blocking factor is lower than max_blocking_factor, the limit is used implicitely.

rsdb/max_in_blocking_factor
This parameter, analogously to rsdb/max_blocking_factor, gives the upper limit for the number of entries to be processed from [itab] if the concrete statement is reflected on an IN clause (see prefer_in_itab_opt).

Analogously to rsdb/max_blocking_factor also the limit of the blocking factor is used instead of rsdb/max_in_blocking_factor, if otherwise the upper limits of the database system would be exceeded.

rsdb/prefer_fix_blocking
If the number of entries in [itab] is not divisible by max_blocking_factor, less entries (conditions) are allocated to the last statement which has been generated for processing the FOR ALL ENTRIES statement. The result is a new statement.
If the same FOR ALL ENTRIES statement is executed very frequently with a different number of entries in the input table [itab], different statements are created up to the maximum of max_blocking_factor statements.
This can be avoided by the above profile parameter.
If this parameter is set to "1", at most two statements of different length are generated. This is achieved by repeating the last value in the input table as if [itab] has been padded to the blocking factor ([itab] is not really modified).

rsdb/min_blocking_factor
If this parameter is set to a value larger than "0" AND if rsdb/prefer_fix_blocking is set, 2 different blocking factors are used: a smaller (min_blocking_factor) and a larger factor (max_blocking_factor).
However, the min_blocking_factor is only used if there are only a few entries in [itab]: A little simplified, if the following applies: "Entries [itab] < max_blocking_factor / 2"

rsdb/min_in_blocking_factor
This parameter works in conjunction with rsdb/min_blocking_factor, for the case that the addition FOR ALL ENTRIES has been implemented with an IN clause (see prefer_in_itab_opt).

Control over FOR ALL ENTRIES Hints
Under the heading Database Interface Hints, Note 129385 describes the options you have for influencing the database interface by entering hints. The hints are evaluated in the database interface itself and are not passed on to the database.

Starting with kernel Release 4.6B all the above mentioned FOR ALL ENTRIES parameters can be set via such a hint for a single statement. In the example:
SELECT * FROM [..] FOR ALL ENTRIES IN [..] WHERE [..]
%_HINTS ORACLE '&prefer_in_itab_opt 1&&prefer_fix_blocking -1&'.
This way, the boolean parameter 'prefer_in_itab_opt' is explictly set and the boolean parameter 'prefer_fix_blocking' is set to its default value.

FOR ALL ENTRIES hints, like hints are generally only used as a a corrective device in emergency situations; Note 129385 goes into this. The hints described here should only be used with careful consideration.


(2) 评论    (91) 引用   

手动处理IDoc需要的两个系统程序

Inbound RSEINB00
Outbound RSEOUT00

Inbound处理流程
有些遗留系统无法产生iDoc 只导出了flat file
此时自己编写程序读入flat file产生idoc文件,之后调用 RSEINB00来处理此IDOC
WE57来修改处理相应iDoc type的funciton module

Outbound处理流程
自己编写程序从生成idoc文件,之后调用 RSEOUT00
在目标系统用WE02来check接受idoc的status

另附两参考文章
Incoming IDOCS - Processing program https://www.sdn.sap.com/irj/sdn/message?messageID=553210
RSEINB00 flat file to idoc uploading in XI https://www.sdn.sap.com/irj/sdn/message?messageID=3280284


(0) 评论    (69) 引用   

如何得到package下面的所有Dev Object与rename产生的诡异问题

Use FM RS_GET_OBJECTS_OF_DEVCLASS.
We can also extract objects in table TADIR

诡异问题:
建立程序Z1 挂在package ZPK下
此刻package和Z1名字都要有改变。因为package没有rename,所以只好新建。此刻程序rename掉,挂在新的package下面。
此刻再删除老的package ZPK就不行了,总是提示有object挂在它下面。可是SE80看不到任何东西。
但是此刻去TADIR表中差,你会发现,rename前的程序还存在于表中,并挂在了老的package下。

SM30 维护一下那条记录,将program的package改为$TMP,之后这个package可删除了。
或者讲这个package所在的transport request release掉,也可以删除了。


(0) 评论    (5) 引用   

如何得到系统table和自定义type的信息

How to get info of system table or the type we defined in program?
Please refer follwing codes i wrote, we can leverage two FM.

REPORT zdavid_component .

TYPES: BEGIN OF t_typ,
line TYPE char100,
END OF t_typ.
DATA: wa_typ TYPE t_typ,
it_typ TYPE TABLE OF t_typ,
it_data TYPE TABLE OF t_typ.

wa_typ-line = '1111'.
APPEND wa_typ TO it_typ.

DATA: tbl_name TYPE x030l-tabname,
it_flds TYPE TABLE OF rfc_fields.
tbl_name = 'MARA'.

CALL FUNCTION 'DP_GET_FIELDS_FROM_TABLE'
EXPORTING
tabname = tbl_name
TABLES
data = it_data
fields = it_flds
EXCEPTIONS
dp_invalid_table = 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.

DATA: it_components TYPE TABLE OF rstrucinfo.
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
program = sy-repid
fieldname = 'wa_typ'
TABLES
components = it_components.

WRITE 'End'.


(0) 评论    (96) 引用   

CHECK,EXIT,STOP etc...

Check
If the check statement appears in a LOOP process block, the unfufilled condition check will stop processing rest codes and do next loop.
If the check statement appears in a EVENT block, the unfufilled condition check will stop current event process and jump to next evetn.

EXITIf you use the EXIT statement within an event block but not in a loop, the system stops processing the block immediately.If the EXIT statement occurs in a loop using DO, WHILE, or LOOP, it is the loop that terminates, not the processing block.

STOP
If you use the STOP statement within an event block, the system stops processing the block immediately.Before and during selection screen processing, the next event in the prescribed sequence is always called. From the AT SELECTION-SCREEN event onwards, the system always jumps from a STOP statement directly to the END-OF-SELECTION statement. Once the corresponding event block has been processed, the system displays the list.

RETURN
If the return occurs in a subroutine, the system will jump out the subroutine processing. If the return occurs in event block processing, system will stop the program directly.
e.g.
START-OF-SELECTION.
PERFORM frm_test.
return.
WRITE / 'start of selection'.

END-OF-SELECTION.
WRITE / 'end of selection'.
*&---------------------------------------------------------------------*
*& Form frm_test
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM frm_test.
DO 5 TIMES.
IF sy-index = 2.
RETURN.
WRITE 'IF STATEMENT'.
ENDIF.
WRITE: 'DO', sy-index.
ENDDO.
WRITE / 'END'.
ENDFORM. "frm_test


(1) 评论    (62) 引用   

ABAP CHECKBOX 和LISTBOX使用

REPORT ZJC20051014_1.

TYPE-POOLS: VRM. "存放combobox内容的type pool

DATA: NAME TYPE VRM_ID, "list box的名称

LIST TYPE VRM_VALUES, "list box的值

VALUE LIKE LINE OF LIST."list box的结构

*定义checkbox,指定command,为了能够响应选择屏幕中值的改变

PARAMETERS: P_CB1 TYPE C AS CHECKBOX DEFAULT 'X' USER-COMMAND CHECK,

P_CB2 TYPE C AS CHECKBOX DEFAULT 'X' USER-COMMAND CHECK.

*定义listbox,必须指定visible length

PARAMETERS: P_LIST1(10) TYPE C AS LISTBOX

VISIBLE LENGTH 15 ,

P_LIST2(20) TYPE C AS LISTBOX

VISIBLE LENGTH 25 .

*开始执行

AT SELECTION-SCREEN OUTPUT .

*选择1而没有选择2

IF P_CB1 = 'X' AND P_CB2 = ''.

*向listbox里面添加值

REFRESH LIST .

VALUE-KEY = '1111111111' . "这个就是变量P_LIST的值

VALUE-TEXT = '1111111111' . "这个是text

APPEND VALUE TO LIST .

VALUE-KEY = '2222222222' .

VALUE-TEXT = '2222222222' .

APPEND VALUE TO LIST .

VALUE-KEY = '3333333333' .

VALUE-TEXT = '3333333333' .

APPEND VALUE TO LIST .

*调用函数显示listbox里面的值

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = 'P_LIST1'

VALUES = LIST.

*把第二个listbox的值清空,并且不能输入

CLEAR P_LIST2 .

LOOP AT SCREEN .

IF SCREEN-NAME = 'P_LIST2' .

SCREEN-INPUT = 0 .

MODIFY SCREEN .

ENDIF .

ENDLOOP .

*选择2,没有选择1,同上

ELSEIF P_CB2 = 'X' AND P_CB1 = ''.

REFRESH LIST .

VALUE-KEY = 'AAAAAAAAAAAAAAAAAAAA' .

VALUE-TEXT = 'AAAAAAAAAAAAAAAAAAAA' .

APPEND VALUE TO LIST .

VALUE-KEY = 'BBBBBBBBBBBBBBBBBBBB' .

VALUE-TEXT = 'BBBBBBBBBBBBBBBBBBBB' .

APPEND VALUE TO LIST .

VALUE-KEY = 'CCCCCCCCCCCCCCCCCCCC' .

VALUE-TEXT = 'CCCCCCCCCCCCCCCCCCCC' .

APPEND VALUE TO LIST .

APPEND VALUE TO LIST .

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = 'P_LIST2'

VALUES = LIST.

*清空listbox 1的值

CLEAR P_LIST1 .

LOOP AT SCREEN .

IF SCREEN-NAME = 'P_LIST1' .

SCREEN-INPUT = 0 .

MODIFY SCREEN .

ENDIF .

ENDLOOP .

*都没有选择,都清空且不能输入

ELSEIF P_CB1 = '' AND P_CB2 = '' .

CLEAR: P_LIST1,P_LIST2 .

LOOP AT SCREEN .

IF SCREEN-NAME = 'P_LIST1' .

SCREEN-INPUT = 0 .

MODIFY SCREEN .

ENDIF .

ENDLOOP .

LOOP AT SCREEN .

IF SCREEN-NAME = 'P_LIST2' .

SCREEN-INPUT = 0 .

MODIFY SCREEN .

ENDIF .

ENDLOOP .

*都选,执行

ELSEIF P_CB1 = 'X' AND P_CB2 = 'X' .

REFRESH LIST .

VALUE-KEY = '1111111111' .

VALUE-TEXT = '1111111111' .

APPEND VALUE TO LIST .

VALUE-KEY = '2222222222' .

VALUE-TEXT = '2222222222' .

APPEND VALUE TO LIST .

VALUE-KEY = '3333333333' .

VALUE-TEXT = '3333333333' .

APPEND VALUE TO LIST .

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = 'P_LIST1'

VALUES = LIST.

REFRESH LIST .

VALUE-KEY = 'AAAAAAAAAAAAAAAAAAAA' .

VALUE-TEXT = 'AAAAAAAAAAAAAAAAAAAA' .

APPEND VALUE TO LIST .

VALUE-KEY = 'BBBBBBBBBBBBBBBBBBBB' .

VALUE-TEXT = 'BBBBBBBBBBBBBBBBBBBB' .

APPEND VALUE TO LIST .

VALUE-KEY = 'CCCCCCCCCCCCCCCCCCCC' .

VALUE-TEXT = 'CCCCCCCCCCCCCCCCCCCC' .

APPEND VALUE TO LIST .

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = 'P_LIST2'

VALUES = LIST.

ENDIF .

START-OF-SELECTION .

*输出到第二屏幕看看

WRITE: P_LIST1 ,/ P_LIST2 .


(0) 评论    (92) 引用   

Very useful functions of ABAP

ABAP_DOCU_DOWNLOAD - Download ABAP documentationin HTML format.

ARFC_GET_TID - will return the IP addressof the terminal in hex.

BAL_* -All function modules used for SAP's application logging can be found here.

BP_EVENT_RAISE -Trigger an event from ABAP/4 program

BP_JOBLOG_READ -Fetch job log executions

CLOI_PUT_SIGN_IN_FRONT - Place the negative signafter a number. SAP default is place the negative sign after the number.

CLPB_EXPORT -Export a text table to the clipboard (on presentation server)

CLPB_IMPORT - Import a Text Table fromthe Clipboard (on presentation server)

COMMIT_TEXT -To load long text into SAP

CONVERSION_EXIT_ALPHA_INPUT - converts any number into a string fill with zeroes-right

example:

input = 123

output = 0000000000000...000000000000123

CONVERSION_EXIT_ALPHA_OUTPUT - converts any number with zeroes-right into asimple integer

example:

input = 00000000000123

output = 123

CONVERT_OTF - Convert SAP documents (SAPScript) to othertypes.

example:

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

IMPORTING

BIN_FILESIZE = FILE_LEN

TABLES

OTF = OTFDATA

LINES = PDFDATA

EXCEPTIONS

ERR_MAX_LINEWIDTH = 1

ERR_FORMAT = 2

ERR_CONV_NOT_POSSIBLE = 3

OTHERS = 4.

DATE_GET_WEEK - will return the week that adate is in.

DATE_CHECK_PLAUSIBILITY - Check to see if a date isin a valid format for SAP. Works well when validating dates being passedin from other systems.

DOWNLOAD -download a file to the presentation server (PC)

DYNP_VALUES_READ - Read the values from adynpro. This function can be used to read the values from a report'sselection screen too (Another example).

DYNP_VALUES_UPDATE - Similar to DYNP_VALUES_READ, this function will allow the updating of fields on a dynpro. Very useful when you want to change a field based on the value entered foranother field.

ENQUE_SLEEP - Wait a specified period oftime before continuing processing.

ENQUEUE_ESFUNCTION - Lock an abap program sothat it cannot be executed. Set the parameters as follows:

RELID = 'ZZ'
SRTF2 = 0
SRTF = (your report name)

Please note that you should not useSY-REPID to pass your report name to the function. The value of SY-REPIDwill change as it is being passed to the function module, and will no longerhold the value of the calling report.

EPS_GET_FILE_ATTRIBUTES - Pass in a filename and a path, and will return attributes for thefile

EPS_GET_DIRECTORY_LISTING -return a list of filenames from a local or network drive

F4_DATE - displays a calendar in apopup window and allows user to choose a date, or it can be displayed readonly.

F4IF_SHLP_EXIT_EXAMPLE - documents the different reasons to use a search help exit, and showshow it is done.

FILENAME_GET -popup to get a filename from a user, returns blank filename if user selectscancel

FTP_CONNECT - Open a connection (and login) to an FTP server

FTP_COMMAND - Execute a command on theFTP server

FTP_DISCONNECT - Close the connection (andlog off) the FTP server

FORMAT_MESSAGE - Takes a message id andnumber, and puts it into a variable. Works better than WRITE_MESSAGE, sincesome messages use $ as a place holder, and WRITE_MESSAGE does not accommadatethat, it only replaces the ampersands (&) in the message.

GET_GLOBAL_SYMBOLS - Returns a list of all tables, select options, texts, etc for aprogram. Even includes the text definitions for the selection screen

GET_INCLUDETAB - Returns a list of allINCLUDES in a program

G_SET_GET_ALL_VALUES -Fetch values from a set.

Function Group GRAP is now obsolete. SAPrecommends using functions in function group SFES instead. Below is an overviewof the changes.

GUI_CREATE_DIRECTORY - Create a directory on thepresentation server

GUI_DELETE_FILE - Replaces WS_FILE_DELETE.Delete a file on the presentation server

GUI_DOWNLOAD - Replaces WS_DOWNLOAD. Download table from the app server to presentation server

GUI_EXEC - Replaces WS_EXECUTE. Start a File or Program Asynchronously with WinExec

GUI_GET_DESKTOP_INFO - Replaces WS_QUERY. DeliversInformation About the Desktop (client)

GUI_REMOVE_DIRECTORY - Delete a directory on thepresentation server

GUI_RUN - Start a File or ProgramAsynchronously with ShellExecute

GUI_UPLOAD - Replaces WS_UPLOAD. Upoad file from presentation server to the app server

HELP_START - Display help fora field. Useful for doing AT SELECTION SCREEN ON VALUE REQUEST for thosefields that do not provide F4 help at the DDIC level.

HOLIDAY_GET - Provides a table of all the holidays based upon a Factory Calendar&/ Holiday Calendar.

HR_DISPLAY_BASIC_LIST - is an HR function, but canbe used for any data. You pass it data, and column headers, and itprovides a table control with the ability to manipulate the data, and send itto Word or Excel. Also see the additional documentation here.

HR_GET_LEAVE_DATA - Get all leave information(includes leave entitlement, used holidays/paid out holidays)

INIT_TEXT -To load long text into SAP

K_WERKS_OF_BUKRS_FIND - Return a list of all plantsfor a given company code.

LIST_TO_ASCII -convert an ABAP report (displayed on screen) from OTF to ASCII format LIST_FROM_MEMORY - Retrievesthe output of a report from memory when the report was executed using SUBMIT...EXPORTING LIST TO MEMORY. See also WRITE_LIST.

MONTH_NAMES_GET -It returns all the month and names in repective language.

MS_EXCEL_OLE_STANDARD_OLE -will build a file, and automatically start Excel

OTF_CONVERT - wraps several otherfunction modules. Will convert OTF to ASCII or PDF

CONVERT_OTFSPOOLJOB_2_PDF -converts a OTF spool to PDF (i.e. Sapscript document)

CONVERT_ABAPSPOOLJOB_2_PDF -convert abap spool output to PDF

POPUP_TO_CONFIRM_LOSS_OF_DATA -Create a dialog box in which you make a question whether the user wishes toperform a processing step with loss of data.

POPUP_TO_CONFIRM_STEP - Create a dialogbox in which you make a question whether the user wishes to perform the step.

POPUP_TO_CONFIRM_WITH_MESSAGE -Create a dialog box in which you inform the user about a specific decisionpoint during an action.

POPUP_TO_CONFIRM_WITH_VALUE -Create a dialog box in which you make a question whether the user wishes toperform a processing step with a particular object.

POPUP_TO_DECIDE -Provide user with several choices as radio buttons

POPUP_TO_DECIDE_WITH_MESSAGE - Create a dialog box inwhich you inform the user about a specific decision point via a diagnosis text.

POPUP_TO_DISPLAY_TEXT -Create a dialog box in which you display a two-line message.

POPUP_TO_SELECT_MONTH - Popup to choose a month

POPUP_WITH_TABLE_DISPLAY -Provide a display of a table for user to select one, with the value of thetable line returned when selected.

PRICING - Return pricing conditionsin an internal table. Use structure TCOMK for parameter COMM_HEAD_1, andstructure TCOMP for parameter COMM_ITEM_1, and set CALCULATION_TYPE to B. The pricing conditions will be returned in XOMV. You must fill TCOMP, andTCOMK with the appropriate values before callling the function in order for itto work.

PROFILE_GET - Read an Entry in an INIFile on the frontend

PROFILE_SET - Write an Entry in an INIFile on the frontend

READ_TEXT -To load long text into SAP

REGISTRY_GET - Read an Entry from theRegistry

REGISTRY_SET - Set an entry in theRegistry

RFC_ABAP_INSTALL_AND_RUN - Runs an ABAP program that is stored in the table PROGRAM when theMODE = 'F'. Table WRITES contains the ouput of the program. Allows you torun a program without having the source code in the target system.

RH_GET_ACTIVE_WF_PLVAR - Return the active HR Plan

RH_GET_DATE_DAYNAME - return the day based on thedate provied

RH_START_EXCEL_WITH_DATA -startsExcel with the contents of an internal table. This function finds Excelin the desktop registry. It also uses a local PC working directory to save thefile (that's what the "W" value for data path flag does). Verytransparent to user!

RH_STRUC_GET -Returns all related org info

RP_CALC_DATE_IN_INTERVAL - Add/subtractyears/months/days from a date

RP_LAST_DAY_OF_MONTHS -Determine last day of month

RPY_DYNPRO_READ - Read dynpro, includingscreen flow

RPY_TRANSACTION_READ - Given a transaction, returnthe program and screen or given a program and screen, return the transactionsthat use the program and screen.

RS_COVERPAGE_SELECTIONS - Returns an internal tablethat contains a formatted list of all the selection parameters entered for a report. Table is ready to print out.

RS_REFRESH_FROM_SELECTOPTIONS -Get the current contents of selection screen

RS_SEND_MAIL_FOR_SPOOLLIST -Send message from ABAP/4 program to SAPoffice.

RS_VARIANT_CONTENTS -Returns the contents of the specified variant in a table.

RZL_SLEEP -Hang the current application from to 5 seconds.

RZL_SUBMIT -Submit a remote report.

RZL_READ_DIR_LOCAL -Read a directory on the Application Server

RZL_READ_DIR - If the server name is leftblank, it reads a directory from local presentation server, otherwise it readsthe directory of the remote server

RZL_READ_FILE - Read a file from thepresentation server if no server name is given, or read file from remoteserver. Very useful to avoid authority checks that occur doing an OPENDATASET. This function using a SAP C program to read the data.

RZL_WRITE_FILE_LOCAL - Saves table to thepresentation server (not PC). Does not use OPEN DATASET, so itdoes not suffer from authority checks!

SAPGUI_PROGRESS_INDICATOR - Display a progress bar onthe SAP GUI, and give the user some idea of what is happening

SAVE_TEXT -To load long text into SAP

SCROLLING_IN_TABLE -Ifyou are coding a module pool and using a table-control, you can use thisfunction SCROLLING_IN_TABLE to handle any scrolling.(provided by Paul Kjaer)

SD_DATETIME_DIFFERENCE - Give the difference in Days and Time for 2dates

SO_NEW_DOCUMENT_ATT_SEND_API1 - Send a document as part ofan email. The documentation is better than normal for this function, so pleaseread it.

SO_SPLIT_FILE_AND_PATH -Split a fully pathed filename into a filename and a path.

SO_SPOOL_READ -Fetch printer spool according to the spool number informed.

SO_WIND_SPOOL_LIST -Browse printer spool numbers according to user informed.

SX_OBJECT_CONVERT_OTF_PDF - Conversion From OTF to PDF(SAPScript conversion)

SX_OBJECT_CONVERT_OTF_PRT - Conversion From OTF to PrinterFormat (SAPScript conversion)

SX_OBJECT_CONVERT_OTF_RAW - Conversion From OTF to ASCII(SAPScript conversion)

SXPG_CALL_SYSTEM - you can check theuser's authorization for the specified command and run the command. The commandruns on the host system on which the function module is executed. The functionmodule is RFC-capable. It can therefore be run on the host system at which auser happens to be active or on another designated host system at which an R/3server is active.

SXPG_COMMAND_LIST_GET - Select a list of externalOS command definitions.

SXPG_COMMAND_DEFINITION_GET - Read the definition of asingle external OS command from the R/3 System's database.

SXPG_COMMAND_CHECK - Check whether the user isauthorized to execute the specified command on the target host system with thespecified arguments.

SXPG_COMMAND_EXECUTE - Check a user'sauthorization to use a command, as in SXPG_COMMAND_CHECK. If the authorization check is successful, then execute the commandon the target host system.

TERMINAL_ID_GET -Return the terminal id

TH_DELETE_USER - Logoff a user. Similar results to using SM04.

TH_ENVIRONMENT - Get the UNIX environment

TH_POPUP -Display a popup system message on a specific users screen.

TH_REMOTE_TRANSACTION - Run a transaction on aremote server. Optionally provide BDC data to be used in the transaction

TH_USER_INFO - Give information about thecurrent user (sessions, workstation logged in from, etc)

TH_USER_LIST - Show which users are loggedinto an app server

UNIT_CONVERSION_SIMPLE -convert weights from one UOM to another.

UPLOAD -upload a file to the presentation server (PC)

UPLOAD_FILES - Will load one or more filesfrom app or presentation server

WRITE_LIST -Usefulfor writing out the list contents that result from the function LIST_FROM_MEMORY.

WS_DOWNLOAD -Save Internal Table as File on the Presentation Server

WS_EXCEL -Start EXCEL on the PC

WS_EXECUTE -execute a program on a windows PC

WS_FILE_DELETE -Delete File at the Frontend

WS_FILENAME_GET -Call File Selector

WS_MSG -Create a dialog box in which you display an one-line message.

WS_UPLOAD - Load Files fromthe Presentation Server to Internal ABAP Tables

WS_VOLUME_GET -Get the label from a frontend device.

WWW_LIST_TO_HTML - After running a report, call this function toconvert the list output to HTML.

(3) 评论    (91) 引用   

正确地使用SAP的标准对话框函数

http://blog.csdn.net/cissor/archive/2007/02/12/1508552.aspx

(0) 评论    (93) 引用   

ABAP常用fuction

http://blog.csdn.net/cissor/archive/2007/02/07/1504905.aspx

-----------------------------------------------------
获取生产定单状态
-----------------------------------------------------
call function 'STATUS_TEXT_EDIT'
EXPORTING
flg_user_stat = 'X'
objnr = LO_OBJNR
only_active = 'X'
spras = sy-langu
IMPORTING
line = ls_statu
EXCEPTIONS
object_not_found = 01.


使用:objnr 状态对象号,only_active 激活的 ,


-----------------------------------------------------

--------------------------------------------------
获取每个月的最后一天
---------------------------------------------------
CALL FUNCTION 'LAST_DAY_OF_MONTHS'
EXPORTING
day_in = date
IMPORTING
last_day_of_month = date1.

-------------------------------------------------------

--------------------------------------------------------------
去掉前面0
*&--------------------------------------------------------------------*
*& Form frm_alpha_output 去零
*&--------------------------------------------------------------------*
DEFINE alpha_minus.
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = &1
importing
output = &1.
END-OF-DEFINITION.

---------------------------------------------------
前面加0
---------------------------------------------------
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = &1
importing
output = &1.

------------------------------------------------

踢用户
TH_DELETE_USER
---------------------------------------
CALL FUNCTION 'CUT_2BYTES_STRINGS'
EXPORTING
I_STR = T_STR
I_LEN = 4
IMPORTING
O_STR = T_TXT04
T_STR 输入字符 I_LEN 长度 T_TXT04输出字符

金额转换成大写
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = T_AMOUNT10
CURRENCY = 'RMB'
LANGUAGE = '1'
IMPORTING
IN_WORDS = S_AMWORD2
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS = 3.

把SAP里的负号放到前面来的函数
CLOI_PUT_SIGN_IN_FRONT
使用示例

DATA : t(10) TYPE c VALUE '65465-' .

CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = t.

write : t .

-------------------------------------------
通过这个日期得出那天是星期几
DAY_IN_WEEK

----------------------------------------
用来得到将来/过去的日期的
RP_CALC_DATE_IN_INTERVAL

-------------------------------------------
日期的加减
BKK_ADD_MONTH_TO_DATE
--------------------------------------------------------------------


一组有用的用户交互窗口函数
POPUP_TO_CONFIRM_LOSS_OF_DATA 显示有YES/NO的弹出窗口,提示用户未保存的数据将丢失

POPUP_TO_CONFIRM_STEP 提示是否确认操作的弹出窗口

POPUP_TO_CONFIRM_WITH_MESSAGE 可以显示定制的提示信息的确认窗口

POPUP_TO_CONFIRM_WITH_VALUE 显示确认用户对某个特定对象的操作的弹出窗口

POPUP_TO_DECIDE 将待确认选项以单选按钮的方式显示的弹出窗口

POPUP_TO_DECIDE_WITH_MESSAGE 带消息的确认窗口

POPUP_TO_DISPLAY_TEXT 显示多行信息的窗口

POPUP_TO_SELECT_MONTH 月份选择窗口

POPUP_WITH_TABLE_DISPLAY 有表格对象的确认窗口


一组操纵客户端文件系统的函数
GUI_CREATE_DIRECTORY 在PC上建立文件目录

GUI_DELETE_FILE 删除PC上的文件

GUI_DOWNLOAD 文件下载函数

GUI_EXEC 执行PC上的程序,或者打开文件

GUI_GET_DESKTOP_INFO 得到PC客户端的系统信息,比如操作系统等

GUI_REMOVE_DIRECTORY 删除PC目录

GUI_RUN 运行PC程序(ShellExecute)

GUI_UPLOAD 从PC上传程序


判断某天是否是假日
HOLIDAY_CHECK_AND_GET_INFO

ABAP_DOCU_DOWNLOAD
Download ABAP documentation in HTML format.

GET_CURRENT_YEAR
得到当前的财政年(fiscal year)


察看某日期的属性,包括该日期是星期几,第几天(周2=2),是不是公共假期等,需要输入国家日历。

DAY_ATTRIBUTES_GET

Return useful information about a day. Will tell you the day of the week as a word (Tuesday), the day of the week (2 would be Tuedsay), whether the day is a holiday, and more.(provided by Francois Henrotte)?




CLPB_IMPORT :从剪贴板导入internal table
CLPB_EXPORT:从internal table输入到剪贴板

示例程序:GRCLPB_1

在SE38环境下的程序名输入栏输入'DEMO*'后按F4,你可以查到SAP所有的DEMO示例程序,会学到很多ABAP功能的实现方法,输入'BCALV*'后按F4,你可以查到很多ALV示例程序

(1) 评论    (738) 引用   

List of ABAP Functions

(0) 评论    (53) 引用   

good sample and tutorial about ALV

(0) 评论    (91) 引用   

build search help manually in ABAP

FORM frm_f4_help TABLES it_value_table
USING pa_retfield TYPE dfies-fieldname
pa_dynpprog TYPE sy-repid
pa_dynpnr TYPE sy-dynnr
pa_dynprofield TYPE help_info-dynprofld
pa_text TYPE c
pa_value_s TYPE ddbool_d.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = pa_retfield
dynpprog = pa_dynpprog
dynpnr = pa_dynpnr
dynprofield = pa_dynprofield
window_title = pa_text
value_org = pa_value_s
TABLES
value_tab = it_value_table
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
ENDFORM. " FRM_F4_HELP


(0) 评论    (190) 引用   

Display Hierarical ALV list

https://www.sdn.sap.com/irj/sdn/thread?messageID=1680326&#1680326

(0) 评论    (193) 引用   

How to search for BAdIs?

https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3480

(0) 评论    (88) 引用   

RFC and BAPI

from internet:

BAPIRFC不是同一个层次上概念,不能说从字面上看到BAPI函数和RFC函数就认为他们之间有必然的联系和区别。打个比如,问一个问题:人可以分为哪几类,答曰:男人和老人,呵~~,大家都知道,男人是基于性别来说的,老人是基于年龄的。BAPISAP提供的基于业务对象的函数,关键是它们处理的对象是R/3的业务相关business object),比如单据类销售订单,组织:公司等,它们是一系列实体。RFC则是一种系统间通讯的方式(Remote Funciton Call),一个男人可能同时也是一个老人,一个BAPI函数往往能是一个RFC函数(我不知道是不是所有BAPI都可以有基于RFC技术来调用,但是至少也可以说大部分吧,VB里面用BAPI,就是因为这个BAPI函数具有RFC的特性)

BAPI是个SAP里一个很好的思想,把业务对象都对象化了。刚学ABAP/4时,并不能理解SAP所说?ABAP/4?中的?4?,而觉得它更像是一种脚本语言,顶多也就是和C一样,但是自从我接触了BAPI之后,我才体会到SAPABAP是种4G语言的确不虚。 当在外部调用BAPI的时候,比如VB,就可以把SAP里的诸如订单,物料,员工,工厂等作为一个对象来处理,而且这种处理又是那么的简单,可能只要几句代码就可以了,最关键就是:1.收集BAPI函数所要的数据,也就是BAPI输入参数,VB也好,SAP本身的 Screen也好,甚至Web页面也好,只不过是一个数据收集器!(要作一些必要的数据检查保证它们是正确的,不过即使不正确也没有关系,BAPI会返回错误信息) 收集完成了,就送给BAPI作为参数,剩下的事都是BAPI给做了,你就不用管了! 2.接收BAPI返回的信息,也就是BAPI输出参数,并把它们?翻译?成恰当的形式给表达给用户。

(0) 评论    (52) 引用   

SAP User-exits List

http://www.planetsap.com/userexit_main_page.htm
http://www.planetsap.com/Userexit_List.htm

SAP所有模块用户出口
T-Code:CMOD(实用程序?>SAP增强)

用户出口名称 短文本描述
0VRF0001 客户指定路线确定
AAIC0001 IM 总结: 在选择后处理数据
AAIC0002 IM 总结: 在选择后处理指定的输入项
AAIP0001 IM 追溯: 实际价值对预算类别的分配
AAIP0002 IM 追溯: 定义用户定义的指标
AAIP0003 IM 追溯: 定义用户定义的特性
AAIR0001 IM-IS: 适用请求报表中的用户值字段
AAIR0002 IM-FA: 拨款申请的用户字段
AAIR0003 IM: 创建拨款申请中的 PM 定单时工作场所的分配
AAIR0004 IM 追溯: 定义用户定义的特性
AAIS0003 投资计量对资产的实际结算
AAIS0004 全部计划值或预算值的结算
AAPM0001 资产会计和工厂维护的集成
ACBAPI01 会计核算: 对 BAPI 界面的客户增强功能
ACCID001 会计核算的 IDoc 过程
ACCID002 支出会计的 IDoc 处理
ACCOBL01 代码块中 PAI 和 PBO 的客户出口
AD010001 更改对象清单及其层次
AD010002 定界选择和/或过滤已定数据
AD010003 创建自定义动态项目特性
AD010005 创建自定义资源
AD010006 菜单退出:更改动态项目值
AD010007 更改 DI 处理信息
AFAR0001 External determination of ref. value for dep. calculation
AFAR0002 External determination of depreciation
AFAR0003 外部转换方式
AFAR0004 报废比例值的确定
AINT0001 当记帐资产时进行扩展的检查
AINT0002 出入流水中冲销帐户的替代...
AINT0003 定义投资支持再付款的百分比/金额
AINT0004 更改某范围已过帐金额
AINT0005 虚拟扩展语法检查. 不使用。
AISA0001 分配库存号
AIST0001 主数据维护中的兑换数字范围
AIST0002 资产主数据中的客户字段
ALE00001 ALE 用户退出
ALTD0001 Individual additional checks when transferring old data
AMAV0001 确定资产起息日
AMGS_001 在资产报表中用户定义的转换方法
AMPL0001 AMPL上附加数据地用户子屏幕
AMSP0002 确定两个公司代码间的关系类型
ANLR0001 Additional control level texts in AM reporting
ARVL0001 确定手工重估
ATP00001 有效检查的用户出口
BADA0001 Customer-specific conversion method in asset reports
BADA0002 Customer-specific asset number
BAS00001 Service master: Check service specifications
BASI0001 IDoc服务主数据:内向处理
BASO0001 IDoc服务主数据:出站处理
BATCHCHK 检查批次更改的功能模块退出
BBPIV001 User Exits BBP Invoice Verification
BBPP0001 Fill RESBD Structure from BBP Component Structure
BC621E00 Customer Function for BC621 Group 00
BC621E01 Customer Function for BC621 Group 01
BC621E02 Customer Function for BC621 Group 02
BC621E03 Customer Function for BC621 Group 03
BC621E04 Customer Function for BC621 Group 04
BC621E05 Customer Function for BC621 Group 05
BC621E06 Customer Function for BC621 Group 06
BC621E07 Customer Function for BC621 Group 07
BC621E08 Customer Function for BC621 Group 08
BC621E09 Customer Function for BC621 Group 09
BC621E10 Customer Function for BC621 Group 10
BC621E11 Customer Function for BC621 Group 11
BC621E12 Customer Function for BC621 Group 12
BC621E13 Customer Function for BC621 Group 13
BC621E14 Customer Function for BC621 Group 14
BC621E15 Customer Function for BC621 Group 15
BC621E16 Customer Function for BC621 Group 16
BC621E17 Customer Function for BC621 Group 17
BC621E18 Customer Function for BC621 Group 18
BC621EDX Customer Function for BC621
BDMO0001 Enhancement to the ALE distribution reference model
BG000001 用户出口:担保检查
BG000002 用户出口:担保检查对话框
BG000003 用户出口:修改担保检查结果的子屏幕
BPX00001 业务合伙人:用户退出管理数据
BPX00002 业务合伙人: 用户退出管理数据 (检查)
BPX00003 业务合伙人: 用户退出银行明细 (处理)
BPX00004 业务合伙人: 用户退出银行明细 (编辑)
BPX00005 业务合伙人:用户退出-定义合伙人外部编号
BPX00006 业务合伙人:用户退出-检查合伙人外部编号
BRSTEX01 在报表中自定义层次
C1070001 EHS: 特性值评估实例的附加检查
C10U0001 EHS: 潜在风险的进一步检查
C1C10001 EHS: 报表选择 MSDS 运送的 SRGV 决定
C1CA0001 EHS: 商品安全数据表的决定报表类型
C1CA0002 EHS: 确定 EH&S 中分配给物质的商品标识
C1CA0003 EHS:生成具有MSDS装运的所有物质的表格
C1CA0004 EHS: 决定 MSDS 的语言版本
C1CA0005 EHS: 报表选择 MSDS 运送的 SRGV 决定
C1CA0006 EHS: 报表运送:检查是否代发送
C1G20001 EHS: 菜单退出 1:报告管理
C1G20002 EHS:菜单退出 2:报告管理
CADD0001 菜单增强 CAD 桌面
CADD0002 菜单增强 CAD 桌面
CADD0003 CAD 桌面的客户增强
CADD0004 子屏幕增强 CAD 桌面
CADR001 CAD:技术图形标题管理的 User Exit
CATP0001 确定目标时数
CATS0001 CATS: 构造工作清单
CATS0002 CATS: 数据记录补充
CATS0003 CATS: 无效的记录数据
CATS0004 CATS: 在用户界面中功能无效
CATS0005 CATS: 客户字段增加方式
CATS0006 CATS: 确认全部时间表
CATS0007 CATS: 初始屏幕上的子屏幕
CATS0008 CATS: 确定承认工作流收件人
CATS0009 CATS: 数据输入部分的客户文本字段
CATS0010 CATS: 工作清单中的用户定义文本字段
CATS0011 CATS: 客户功能
CATS0012 CATS: 数据输入屏幕上的子屏幕
CATSBW01 Customer Exit for Time Sheet Data Transfer -> BW
CAVC0000 用户出口: 变量配置: 外部应用程序接口
CAWAO_TS Text Layout of Worklist
CBP00001 用户由于PP-CBP退出
CCOWB001 修改菜单条目的用户退出
CCT00001 User exit characteristics mgmt.: Char. data before backup
CCUCEI0A 已分配的值文件和对象特性
CCUCEI0B 特定客户批量输入处理
CCUCEI0H 更改配置特性的 F4 帮助
CCUCEI0V 搜索带相同数值的物料变式
CCUP0001 报告-计划表
CCUX0000 配置的附加检查
CCUX0001 配置的装载功能
CCUX0002 在类节点上对象查找的冲突反应
CCUX0003 查找类节点中对象的参数
CCUX0004 有附加的确认过帐处理
CCUX0005 按匹配类型传输项目类别
CCUX0006 修补订单 BOM
CCUX0007 定义实例的 BOM 类别
CCUX0008 没有外部获得组件的 BOM 箍?
CCUX0100 同步变式配置初始化
CCUX0500 配置-技术参数-策略表的访问
CCUX0510 配置:改变变体表条目的附加过程
CCUX0800 配置中多层扩展的细节层次
CCUXDATE 定单 BOM 的有效日期
CCUXDATU 面向结果订单 BOM 的展开日期
CCUXDELE 删除分类数据的附加逻辑(CU 视图)
CCUXDYNP 不完善分配的特征值的会话
CCUXIACD 维护例示的附加数据
CCUXINST 修改实例的外部编号分配
CCUXMVAR 多步配置物料变量
CCUXOBTY 类节点对象搜索的对象类型
CCUXSETM 保存 SET 处理的手工更改
CCUXSETQ 设置处理的组件数量
CCUXSTAT 定义例示物料的BOM状态
CEI00000 配置编辑器中客户功能的可用性
CEPEX001 User Exit CEP: Authorization Check for Folder
CIFEVT01 Core Interface with APO: Enhancements for Event Processing
CIFIMO01 Enhancement in Integration Model Creation
CIFLOC01 Enhancement for Transferring Customer-Specific Loc. Fields
CIFLOC02 Enhancement for Transferral of Customer-Spec. Loc. Fields
CIFLZO01 Customer Enhancement for Runtime Object: Splitting of Oper.
CIFMAT01 Enhancement for Transferral of Customer-Specific Matl Fields
CIFORD01 Enhancement for Incoming Orders Interface
CIFORD02 Enhancement for Transferring Customer-Specific Order Fields
CIFORD03 Enhancement for In-House Prod. Order Inc.for Customer Fields
CIFORD04 Determine Rework Operations or Triggering Operation
CIFPCM01 Enhancement for Recipient Processing in Production Campaign
CIFPIR01 Enhancement of Ind. Requirements Inc. for Customer Fields
CIFPPM01 Core Interface for APO: Enhancements for PPM Model
CIFPPM02 Enhancement for Transferral of Customer-Specific PPM Fields
CIFPUR01 Enhancement for Transferring Customer-Specific PO Fields
CIFPUR02 Enhancement of Purchase Order Interface (Incoming)
CIFPUR41 Suppression of Quota Information for APO Transfer
CIFRSV02 Inbound Processing for Manual Reservations
CIFSLS02 Enhancement for Sales Order Interface (Incoming)
CIFSLS03 Influencing of Sales Order Data Prior to Dispatch
CIFSLS04 Influencing of Reservation Data Prior to Dispatch
CIFSRC01 Enhancement for Transferring Customer-Specific SS Fields
CIFSTK01 Enhancement for Transferring Customer-Specific Stock Fields
CKML 用户退出实际成本帐目计算
CLCTMS01 查找对象的默认值
CLCTMS02 相同分类检查
CLCTMS03 查找对象的相关性
CLFM0001 更改或设置对象分类的默认值
CLFM0002 保存前调用分类数据
CLFM0003 检查特性值分配后调用
CLIDL001 Object Table Customizing for Initial Data Transfer
CLMMD001 大量处理的对象选择
CLSC0001 搜索结果的操作
CMDI001 确定 BOM 展开控制
CMFU0001 定义客户特定屏幕布局
CMFU0002 设置时间确认和货物移动的参数
CMW8DL01 Enhancement CIF middleware user exit for delivery (inbound)
CMW8SH01 Enhancement CIF middleware user exit for shipments (inbound)
CNEX0001 PS: User fields
CNEX0002 PS 授权检查
CNEX0003 PS: Customer specific fields standard project definition
CNEX0004 PS: Customer specific fields standard WBS element
CNEX0005 PS: Customer specific fields in process (standard net)
CNEX0006 PS 客户指定字段项目定义
CNEX0007 PS 客户指定字段 WBS 要素
CNEX0008 工艺中的 PS 客户指定字段 (净计划)
CNEX0009 网络中的物料部件
CNEX0010 PS:在LDB PSJ中的客户定义体系
CNEX0011 部件一览上的网络中的 BOM 展开
CNEX0012 由 WBS 编号派生外部网络编号
CNEX0013 订单:用户化增强:缺省项目种类分配
CNEX0014 BOM 传输的外部数据
CNEX0015 更改 BOM 传输的 BOM 数据
CNEX0016 网络表头中的 PS 客户指定字段
CNEX0017 网络图形中客户指定结点信息 (网络维护)
CNEX0018 网络图形中客户指定结点信息 (信息系统)
CNEX0019 网络图形中客户指定结点信息 (标准网络)
CNEX0020 网络图形中 DIN 字段的附加信息 (网络维护)
CNEX0021 层次图形中 DIN 字段的附加信息 (网络维护)
CNEX0022 DIN 字段中的附加信息 (标准网络维护)
CNEX0023 层次图形中的客户指定结点信息
CNEX0024 Gantt 图表/项目计划板中客户指定图形标题
CNEX0025 项目汇总的附加字段
CNEX0026 物料一般检查的客户增加
CNEX0027 客户增加:工厂,储存位置。寻找组件
CNEX0028 检查作业发布
CNEX0029 检查网络发布
CNEX0030 更新 BOM 分配的事件
CNEX0031 进度分析: 收入值计算的用户出口
CNEX0032 传输价格协议中的PS客户功能
CNEX0033 WBS: 已定义检索和替换字符串
CNEX0034 检查 BOM 传输中的新分配
CNEX0035 检查 BOM 传输中的更改
CNEX0036 检查物料单传送的删除部件
CNEX0037 检查刚才创建的组件
CNEX0038 检查更改的组件
CNEX0039 检查网络中组件的删除部分
CO610001 用户退出:装配处理
COCCA001 客户增强到成本中心权限检测
COCCA002 组织权限检查的客户功能
COI20001 人员建立的修改
COI20002 HR 可用性数据的可选择采购
COIB0001 As-Built 分配工具的客户退出
CONF0001 定单确认中的增强
CONFPI01 流程定单确认:计算客户特殊缺省值
CONFPI02 流程定单确认:客户特殊输入检查1
CONFPI03 流程定单确认:工序选择后的客户特殊检查
CONFPI04 流程定单确认:客户特殊输入检查2
CONFPI05 流程定单确认:存储时客户的特殊加强
CONFPI06 流程订单确认:实际数据传送
CONFPM01 PM/SM定单确认:决定客户特殊缺省值
CONFPM02 PM/SM定单确认:客户特殊输入检查1
CONFPM03 PM/SM定单确认:工序选择后的客户特殊检查
CONFPM04 PM/SM定单确认:客户特殊输入检查2
CONFPM05 PM/SM定单确认:储存时的客户特殊增强
CONFPP01 PP定单确认:决定客户特殊缺省值
CONFPP02 PP定单确认:客户特殊输入检查1
CONFPP03 PP定单确认:工序选择后的客户特殊检查
CONFPP04 PP定单确认:客户特殊输入检查2
CONFPP05 PP定单确认:储存时的客户特殊增强
CONFPP06 PP 订单确认: 实际数据传递
CONFPP07 单一屏幕条目: 包含用户定义的子屏幕
CONFPS01 PS确认:决定客户特殊缺省值
CONFPS02 PS 确认:客户特殊输入检查1
CONFPS03 PS确认:工序选择后的客户特殊检查
CONFPS04 PS确认:客户特殊输入检查2
CONFPS05 PS 确认:储存时的客户特殊增强
COOCM001 更改步骤中的冲突
COOCM002 OCM: 顺序比较的比较字段的定义
COOM0001 间接费用百分比的客户功能
COOM0002 客户功能:成本中心应记计算
COOM0003 自动创建结算规则的客户功能
COOMBP01 业务处理: 主记录中用户定义的附加字段
COOMBP03 业务处理: BAPI 增强
COOMEP01 CO-OM: 信息系统 -> 行项目报表
COOMKA01 成本元素主数据的客户字段
COOMKPLV 复制实际数据到计划或复制计划数字
COOMKPT4 客户出口: 复制计划->计划/实际->成本中心计划
COOMKS01 成本中心主数据的客户
COOMKS02 成本中心: 保存时检查
COOMKS03 成本中心: BAPI 增强
COOMLA01 作业类型主数据的客户字段
COOPA_01 内部订单的客户检查模块
COOPA002 主文件维护的客户功能-内部订单
COOPA003 订单主文件用户定义字段
COOPA004 客户功能:打印订单主数据
COPA0001 盈利性分析派生的优化 (CO-PA)
COPA0002 CO-PA 盈利性分析评估的优化
COPA0003 盈利性部分分配的优化 (CO-PA)
COPA0004 货币转换优化 (CO-PA)
COPA0005 实际数据更新优化 (CO-PA)
COPA0006 计划编制优化 (CO-PA)
COPA0007 外部数据传送优化 (CO-PA)
COPA00RE BW/CO-PA Data Transfer
COPCP001 公司间代码成本的用户退出
COPCP002 用户退出物料评估中的销售定单股票评估
COPCP003 用户退出生产资源/工具成本
COPCP004 客户增加的大批量商品
COPCP005 用户退出物料估价(级别U ?
COPCP006 对 CKWB
COZF0001 改变外部处理工序采购申请
COZF0002 修改外购部件的采购申请
CPAU0001 任务清单中认证检查的增强
CPDO0001 为参照工序集测试测量单位
CPRE0001 任务清单中重组检查的增强
CRDTE001 Program Exits for Determining the Downtime of the Resources
CUBX0001 配置:决定上层商品
CUCPDEL1 附加逻辑: 删除分类数据 LO-VC 视图 CBASE
CUCPDELE LO-VC 视图的附加逻辑删除类别数据
CUCQ0001 配置参数文件的附加逻辑选择 (在 FG CUCQ 中)
CUST1 Enhancement to area menu S000 (Office)
CUST2 Enhancement to area menu S000 (Logistics)
CUST3 Enhancement to area menu S000 (Accounting)
CUST4 Enhancement to area menu S000 (Human Resources)
CUST5 Enhancement to area menu S000 (Info Systems)
CUST6 Enhancement to area menu S000 (Tools)
CUST7 增强范围菜单 S000 (逻辑->物料管理)
CV000001 登记文档管理的增强部分
CV110001 DMS: DMS 对话的增强功能 (FB: CV110)
CVDI0001 用户退出:DDS - 保存收件人列表
CVDI0002 用户退出:DDS - 更改屏幕 100 的初始值
CVDI0003 用户退出: DDS - 确定原件
CVDI0004 用户退出: DDS -确定文档部分和版本
CVDI0005 用户退出: DDS -创建配送定单
CVDI0006 用户退出: DDS - 检查部分定单
CVDI0007 用户退出: DDS - 创建初始定单
CVDI0008 用户退出: DDS - 确定上下文
CVDI0009 用户退出: DDS - 访问 ITS
CVDI0010 用户出口:DDS - 确定工作站应用程序
CVDI0011 DDS: 对所有分配包的 ITS 访问
CVDS0001 由于启用应用程序链接 DMS(DOCMAS) 而导致的用户退出
CVEA0001 EHS: 检查商品名称的 Customer exit
CVFE0001 EHS: 选择报告装运的输出设备
CY040001 计划区域的固定
CY040002 指定调度的工序顺序
CY190001 能力计划:更改订单工序
CYPP0001 更改顺序标准和序列
CYPP0002 CYPP: 排序使用的用户定义字段
CYPP0003 CYPP: 布局码的字段
CYPP0004 排序:替换字段内容
CYPP0005 CYPP:用于显示的用户定义字段
CYPP0006 更改字段内容(布局)
DG100001 DG:写更新文档
DG700001 定义确定传输种类的具体国家/模式
DW_BEAC1 Enhancements for BEAC flight system
EAN12801 EAN128:编码、解码、标签打印
F050S001 FIDCMT, FIDCC1, FIDCC2: 退出用户定义的 IDoc 段
F050S002 FIDCC1: 更改 IDoc/不要保存
F050S003 FIDCC2: 更改 IDoc/不要保存
F050S004 FIDCMT, FIDCC1, FIDCC2: 更改出站 IDoc/不要保存
F050S005 FIDCMT, FIDCC1, FIDCC2 Inbound IDoc: 更改 FI 凭证
F050S006 FI 支出 IDoc: 重置 FI 凭证中的清帐
F1040001 坏帐储备金- 计算百分比
F150D001 打印催款通知程序中的个别客户退出
F180A001 资产负债表调整
F40K0001 Manual account statement
F40S0001 Check deposit
F64O0001 增强基金/证券/下单管理
F67A0001 贷款主数据已改善菜单 I 没�顺?
F67A0010 贷款主数据概览数据用户退出
F67A0011 贷款主数据已改善菜单 II 的用户退出
F67A0012 贷款主数据改善菜单III 的用户退出
F67A0013 贷款主数据更新附加数据的用户退出
F67A0014 贷款/银团数据的屏幕改善
F67A0016 贷款融资项目数用户退出
F68SCHKS 检查冲销的凭证
F68SDATB 用户退出冲销事务 - 默认日期 "到"
F68SDATV 撤销交易的用户退出-默认日期?从?
F68STOBE 可修改能撤销的凭证
FARC0001 Enhancements within archiving (FI)
FARC0002 归档 MM 供应商主数据的附加检查
FDBFVDB1 保险费准备基金处理的贷款分类帐结转
FDTAX001 业务FDTA(下载后事件)的增强
FEB00001 Electronic account statement
FEB00002 Interface - external check entry
FEB00003 完成银行报表TITO格式的客户退出
FEB00004 原始数据处理, 用户退出SWIFT MT940
FEB00005 电子银行 - 科目报表对象生成
FEBLB001 冻结标记用户退出
FEDI0001 Function exits for EDI in FI
FEDI0002 FI中EDI DOCS功能存在 - 试は忍崾?
FEDI0003 FI中EDI docs功能存在 - 4鍼EXR段
FEDI0004 FI中EDI docs功能存在 - 厥馐录?
FEDI0005 EDI-ICODS in FI - 电子用户报表/冻结标记的函数存在
FEDI0006 FI 中 EDI-凭证 的功能退出: 保存 IDCR 段
FFMZA001 为支付请求的支付方式用户退出
FICT0001 Exits for inter-company transactions
FIPAYM01 为IDoc FIPARQ01用户退出
FITR0001 用户退出: 删除/重组旅行统计
FITR0002 用户退出: 创建/更改旅行统计
FITR0003 用户退出: 保存旅行 (PR01, PR04, PR05)
FITR0005
FLC10001 FI-LC - entry - upload programs - RGCPCU40
FMC10000 EC-CS: 灵活上载扩展
FMC10001 EC-CS: 用户屏幕扩展
FMC10010 EC-CS 集成: CS 组织单元的外部名称/文本
FMC10011 EC-CS 集成: 数据条目和对帐
FMC40001 EC-CS: 修改货币兑换
FMC50000 EC-CS:确定本币转换的汇率
FMRESERV 专用基金管理
FTGOVSEL 授权声明:用户出口选择运行
FTIAT001 读取属性的模块(特性和文本)
FTISE001 被选TR-TM数据(e.g.为reg.报告)的衍生物
FTRINCON 用户退出以达到确认状态
FTXW0001 DART: Fill additional fields in SAP export structures
FTXW0002 DART: Add data source (table)
FTXW0003 DART: Extensions to DART area menu FTW0
FV45K001 为确定信贷控制范围用户退出
FV970001 增强基金/证券/现金流量计算器
FVBB0001 确定计算基准TZFB
FVCH0001 CH特定增强: Esp.POR
FVD20001 后处理收款改善贷款选择的用户退出
FVDA0001 用户退出: 在 PAI 时间进行贷款支付
FVDA0002 用户退出: 在 PBO 时间支付
FVDB0002 TR-TM-LO: 用户退出过帐界面, 科目确定
FVDD0001 FM TEXT_INTERFACE 中的用户退出
FVDD0002 用户退出凭证选择
FVDD0003 用户退出信件活动的选择
FVNBO001 交易作业 - 字段缺省值
FVP50001 F4 职员帮助(存储在VDZSB)
FVPB0001 用户退出 - 拖欠利息过帐
FVVDK001 SAPscript 凭证手工后处理的用户退出
FVVDP001 结转: 创建/取消/打印提示: 更新
FVVW0105 ISIS 证券 - 证券帐户 - 悠聊?
FVVW0110 ISIS 证券 - 证券帐户转换 - 创建其他流程
FVVW0200 ISIS 证券 - 维护证券帐户主数据
FVZF0001 发布: 排除贷款清单中的单个记录
FVZZEV 收款分配 MARK 用户退出
FWF1001 基金证券:过帐接口
FYTX0001 Control interface for external systems
FYTX0002 Enhancements for tax interface with Max Tax functionality
GDX3AUTH 用户出口功能组 GDX3 (exit_saplgdx3_001)
GLMAST01 主数据的增强 - ALE 总帐科目
GLPLAN00 增强的权限与有效主数据
GLX_MD01 Customer-specific user exits
GLX1028 BAPI_GLflex_GetDocItems 的用户出口 (EXIT_SAPL1028_001)
GRWTAUTH 报表编写器的授权检查
GSETNAME 存在替换集或组名称
GSL1021A 特殊用途分类帐 - 总计记录
GVTRS001 GVTR (SAPFGVTR): 改变结转储记帐户的余额
HRBAS001 特殊人员活动的客户增强功能
HRDECI01 Payroll Construction Industry Allowances/Expenses
HRESSWWW HR: Internet 服务
HRMYC159 Ehancement for customer exit for 159 report
HRMYCTEA Enhancement for Customer Exit for EA form
HROC0001 对 HR 非周期 - 奖金日期的客户增加
HRP08P13 GB Absence Evaluation & Payment Scheme Customer/User Exits
HRPB22LO Company Loan Japan
HRPB25AD Enhancement for address conversion routine
HRPB2901 Customer exit for controlling CUIT/CUIL
HRPBAS01 对于人员编号有效性,用户退出
HRPC0001 HR: PC 卸载授权
HRPC1701 Customer enhancements: Payroll Venezuela
HRPC1702 Enhancements of independent wage type programs
HRPC2901 Customer exits for settlement of salaries
HRPC3201 Enlargements of Mexican customer payroll
HRPC34TX User Exit for Employee Position - Prog. HIDCTAX1 (INDONESIA)
HRPC3701 Extension to Brazilian payroll
HRPC3702 Extension to Brazilian payroll - Unions
HRPC3703 Identification Documents
HRPCAL00 在薪资发放菜单的客户报告的用户退出
HRPCMPVA 变量变元的用户退出 - 程序 RPITIC00
HRPINW01 激励工资: 用户出口
HRPTDW01 时间数据抽取:提供特定用户域数据
HRPTIM01 人力资源时间管理的客户增强功能
HRPTIM02 关于 HR 时间管理的用户退出:应计休假
HRPTIM03 时间管理用户出口: 缺勤定额扣减
HRPTIM04 在 RPTEDT00 处输入数据后对簇 B2 处数据的修改
HRPTIM05 人力资源时间管理 CC1 的用户出口
HRPTIM06 HR 时间管理休假请求的客户增强功能
HRPTIMAB 定义明确地缺勤
HRPTIMAR 时间管理客户增强: 出席/ 毕ǜ?
HRPTIMEW HR 工时管理的用户出口: 频焦ぷ世嘈统隹?
HRPY0001 设置历经数据记录的开始/ 崾掌?
HRPYBW01 Customer enhancement within statements SAPScript
HRPYFR01 HR_FR : GET_QUALIFICATION
HRPYIT01 User Exit for 770 (Italy Only)
HRPYPT01 HR-PT: Rounding mechanism for tax and Soc Sec amounts
HRPYPT02 HR-PT: Layout for RPCIIDP0
HRPYPT03 HR-PT: Employee grouping for coverage rules
HRPYPT04 HR-PT: Retrieval of EH&S and training data (Social Balance)
HRPYPT05 HR-PT: Promotions/Reclassifications (Social Balance)
HRPYZVMD User exit for address field when printing SP notifications
HRPYZVMV User exit for distributor key when creating SP notifications
HRRPAI01 用户退出 FB HR_ENTRY_DATE and HR_LEAVING_DATE
HRTWTAXM User exits for Tax report
HRV1AT01 Customer exits for Norwegian annual tax reporting
HRWAOSQ1 SAP Enhancement for Status Quo Report
IB020001 过滤器组件
IBIP IBIP:处理IBIP数据传输
IBPP0001 从 PP 数据生成时过滤销售产品数据库组件
ICRP0201 搜索帮助 CS_ORG_02: 授权检查
ICRP0202 搜索帮助 CS_ORG_02: 内部编程选择
ICRP0203 搜索帮助 CS_ORG_02: 建议任务
ICSV0001 显示地理位置数据
ICSV0002 Automatic task determination for service notifications
ICSV0003 合伙人选择
ICSV0004 Check PM object and display object information
ICSV0005 决定拒绝的原因-资源相关的票据处理
ICSV0007 用于发货和退货的转储合作伙伴的序列号
ICSV0008 附加合伙人类型确认
IDCP0001 用于打印预编码发票的客户数据
IDCP0002 用于打印预编码交货单的客户数据
IEQM0001 在功能位置为设备安装增加检验
IEQM0002 为设备组织的定义附加检验
IEQM0003 在设备更新前附加检验
IEQM0004 对象被允许为合同伙伴(定单->维护内容)
IEQM0005 对象被允许为SD合同(维护合同->维护内容)
IEQM0006 对象被允许为SD合同(维持维护合同)
IEQM0007 检验/修改主设备中的厂商字段
IHCL0001 使用物料模板创建设备:类/特性
ILOM0001 在保存一个功能定位前的附加检验
ILOM0002 检查位置号的结构时用户退出
IMRC0001 计量点/计量凭证:更新前退出(COMMIT WORK之后)
IMRC0002 计量点:为客户指定功能退出菜单
IMRC0003 计量凭证:为客户指定功能退出菜单
IMRC0004 计量凭证: 根据新计量凭证的标准检查的出口
IMRC0005 测量点: 出口在AUTHORITY_CHECK_IMPT
IMSMCOMM MSM 通讯加强
INTERFAC 数据传送的接口
IPRM0002 确定维护计划的计划日期信息
IPRM0003 用户字段:维护计划
IPRM0004 维护计划 / 项目: 客户检查时间 "保存"
IPRM0005 确定基于性能策略计划的偏移量
IQSM0001 自动序列号分配
IQSM0002 复制对象列表时检验
IQSM0003 序列号,用户为附加数据退出
IQSM0004 序列号,退出序列屏幕后用户退出
IQSM0005 序列号,用户更新时退出
IQSM0007 货物移动存在序列号,用户
IQSM0008 序列号字符字符串检查
ISRE0001 确定银行手续帐户号
ISRE0002 IPD 报告数据恢复
ITOB0001 PM:技术对象主记录数据 include 子屏幕
ITOB0002 ITOB: 字段更改为复制模式
ITOB0003 PM:客户包含车队对象数据的子屏幕
ITOB0004 PM:客户退出车队标识数据:检查
IWMI0001 SM/PM IDOCs 的用户存在
IWO10001 Create a PM sub-order
IWO10002 PM maintenance order: Customer check for order release
IWO10004 维护订单:为订单完成检查客户
IWO10005 维护订单:客户,-说明书。参数文件控制的确定
IWO10006 维护订单:从客户增强中排除Fcode
IWO10007 维护订单:客户增强-订单中的许可证
IWO10008 客户增强:税收管辖权码的确认
IWO10009 PM订单:对于'保存'事件的客户检查
IWO10010 维护订单:为确定WBS元素的客户增强
IWO10011 维护订单:为元件选择的客户增强
IWO10012 维护定单:在中央表头上优先级处理
IWO10015 维护订单:关于工艺的用户字段的F4帮助
IWO10016 PM订单:为检查工艺用户字段的客户增强
IWO10017 通过客户逻辑确定文本订单编号
IWO10018 维护订单:订单抬头的用户字段
IWO10020 维护订单:自动包括任务清单
IWO10021 当从通知创建订单时,自动传输任务清单
IWO10022 从用户退出清单日历
IWO10023 服务订单:更改提前装运凭证的标题数据
IWO10024 服务订单:更改提前装运的项目
IWO10025 PM/SM 订单:查找相应成本中心
IWO10026 设置状态?不执行?的用户检查
IWO10027 用户退出:生成用户定义的结算规则
IWO10029 包含 PM/SM 订单中的商品凭证
IWO10030 预先设置事件对象的字段
IWO10031 PM/SM 定单中隐藏人员编号
IWO20001 PM order: User exit to pass routing to order
IWOC0001 创建PM/SM通知:决定参考对象
IWOC0002 PM/SM通知:检查是否状态改变被允许
IWOC0003 相关对象和计划员组的PM/SM 授权检查
IWOC0004 更改单层清单编辑 PM/QM/SM ALV 设置
J_1AAA01 重估 FI-AA 的基值修改
J_1AAM01 用户-退出AM 路支票打印
J_1AF007 报表J_1AF007的用户退出
J_1AF011 j_1AF011的用户退出
J_1AF012 J_1AF012的用户退出
J_1AF105 每天VAT 报告的用户退出
J_1AF106 带磁性支持的VAT 报告的用户退出
J_1AMM03 用户退出打印MM 路支票
J_1ASD05 在定单项中的用户-退出附加数据(SD)
J_1ASD06 在支票文件中的用户-退出发票参考(SD)
J1BF0001 FI 本地化(巴西):Boleto的附加数据
J1BV0001 巴西地方色彩:SD:Nota财政的装运单元
KAHFEX01 Selection data for commercial reporting in PS
KAP10001 PS:项目层次报表
KAP60001 PS:R/3 EIS 输出项目关键指标
KKAG0001 按订单生产的期间成本核算
KKAG0002 按订单生产的期间成本核算
KKAG0003 按订单生产的期间成本核算
KKAG0004 用动态项目进行结果分析
KKAG0005 结果分析
KKCD0001 SAP-EIS:数据传送的用户已存在
KKCD0002 Data entry user exit before update
KKDR0001 细分报表的全局变量扩展
KKDR0002 细分:虚拟字符和关键数字的来由
KKEK0001 在单位成本核算的用户定义项目录Y
KKP00001 用户定义的部门原料清单
KKRF0001 退出到AUFK增加的分类
KKRF0002 变化特征的 FE -> 客户字段
KKRU0001 用户退出由于概要对象的文本生成
KPSHZIN1 Project interest calc.: Modification of single item table
KPSHZIN2 Project Interest Calculation: Check Line Item Relevance
KPSHZIN4 PS/CO 利息计算:客户指定的更新
KPSPZIN1 项目计划利息计算:读取相关记录
KPSPZIN2 计划利息计算: 检查行项目关联性
KPSPZIN3 计划利息计算单独定义利息计算完成日期
KPSPZIN4 计划利息计算:特定客户更新
KSDIEX01 在与资源有关的开票时确定费用
LASP0001 PP - 序列可视化(订单特性)
LASP0101 lasp:显示所需进度记录序列
LEINS001 统计更新:购买凭证
LES00001 User exits for LES
LFDCB001 SAPLFDCB 退出
LFVZF001 TR-TM-LO: 退出合同-指定检查 FB01
LIFO0040 关于后进先出评估的用户界面
LM61W001 用户存在于功能模块 FORECAST 环境
LMCWZ001 用于 LIS 更新的通讯结构:增强代理
LMDR2001 用户退出opt.pur.ord.-基础的装载bldg约束参数文件
LMDZU001 用户退出附加计划
LMEDR001 打印程序的增强
LMEKO001 Extend communications structure KOMK for pricing
LMEKO002 Extend communications structure KOMP for pricing
LMELA002 一收货入帐时从装运通知采纳批量编号
LMELA010 内部装运通知: 从IDOC传送项目数据
LMEQR001 源确定的用户退出
LMEWPU06 对象确定的客户退出(通过目录采购)
LMEWPU07 客户退出以判定允许目录
LMEWRU01 BAPI BAPI_REQUIREMENT_CREATE 的用户退出
LMEXF001 没有发票收据的采购凭证中的条件
LMR1M001 在后勤发票校验中用户退出
LMR1M002 GR/IR科目维护的科目分组
LMR1M003 在后勤发票校验中的编号分配
LMR1M004 后勤发票校验:后续凭证的项目文本
LMR1M005 后勤发票检验: 为过帐下达冻结凭证
LMR1M006 后勤发票校验: 处理 XML ⑵?
LOI00001 用户进入LOI界面
LVEDF001 用户退出到IDOC_OUTPUT_INVOICE
LWB2B001 贸易合同:贸易合同屏幕出口
LWB2B002 贸易合同:字段控制增强
LWB2B003 贸易合同: 保存前的客户增强功能
LWB2B004 贸易合同: 增强功能
LWB2B005 贸易合同: 检查后续凭证是否被创建
LWB2B006 贸易合同: 影响以参考创建
LWB2B007 贸易合同: 附加检查条件维护
LWB2B008 贸易合同: 附加用户检查
LWBON001 扩展通信结构MCKONA (供应商业务量回扣收入)
LWBON003 在结算凭证创建之前改变结算数据
LWBON004 消息报表的 LIS 更新模拟
LWBON005 结算凭证,安排结算的索引条目
LWSUS001 在零售中单独客户源的确定
LWVK0001 确定每个消费者的价格类型
LWVK1001 用于定价的扩展通讯结构 KOMK
LWVK1002 用于定价的扩展通讯结构 KOMP
LWVK1003 定价项目的客户特定检查
LWVKM001 竞争者: 扩展条目清单抬头 WELPK
LWVKM002 竞争者: 扩展条目清单项目 WELPP
LWZRE001 增强, 代理业务条件确定
LWZRE002 增强, 凭证传送到财务会计
LWZRE003 增强, 信贷限制检查, 收付请求
LWZRE004 增强:结算请求凭证检查
LWZRE005 增强:结算需求,现金折扣决定
LWZRE006 增强:业务代理,结果对象决定
LWZRE007 增强:决定代理业务的发票清单.
LWZRE008 增强:在ஷ


(0) 评论    (857) 引用   

More than 100 ABAP Interview Faq's

http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm 查看全文

(0) 评论    (93) 引用   

动态显示多个ALV报表

http://blueoxygen.dflying.net/3/resources/DYN_ALV.txt.html

(1) 评论    (12) 引用   

reusable BDC subroutine

http://blueoxygen.dflying.net/3/resources/BDC.txt.html

(0) 评论    (188) 引用   

SAP file manipulation sample

http://blueoxygen.dflying.net/3/resources/File.txt.html

(0) 评论    (54) 引用   

ALV Sample

http://blueoxygen.dflying.net/3/resources/ALV.txt.html

(0) 评论    (190) 引用   

[SAP]Subroutine for popup window

http://blueoxygen.dflying.net/3/resources/POP_UP.txt.html

(0) 评论    (195) 引用   

ALV Sample codes snippet

REPORT z_alv_02. *&---------------------------------------------------------------------* *1.Data for declare a instance for cl_gui_alv_grid class named l_alv *&---------------------------------------------------------------------* DATA: l_alv TYPE REF TO cl_gui_alv_grid. *&---------------------------------------------------------------------* *2.Data for declare a instance for cl_gui_custom_container class * named g_custom_container1 *&---------------------------------------------------------------------* DATA: g_custom_container1 TYPE REF TO cl_gui_custom_container. *&---------------------------------------------------------------------* *3.Create a internal table to store field catalog *&---------------------------------------------------------------------* DATA: gt_fieldcatalog TYPE lvc_t_fcat, it_fieldcatalog LIKE LINE OF gt_fieldcatalog. *&---------------------------------------------------------------------* *4.Create a layout structure.----not necessary *&---------------------------------------------------------------------* DATA: gs_layout TYPE lvc_s_layo. *&---------------------------------------------------------------------* *5.Data to deal with OK_CODE *&---------------------------------------------------------------------* DATA: ok_code LIKE sy-ucomm, save_ok LIKE sy-ucomm. *&---------------------------------------------------------------------* *6.Create a internal table to store select result. *&---------------------------------------------------------------------* DATA: lt_sflight TYPE TABLE OF sflight. *&---------------------------------------------------------------------* *7.START-OF-SELECTION. *&---------------------------------------------------------------------* START-OF-SELECTION. SELECT * FROM sflight INTO TABLE lt_sflight. *&---------------------------------------------------------------------* *8.create a instance for cl_gui_custom_container class,an object * named g_custom_container1 *&---------------------------------------------------------------------* *You have to create a screen, put a class control on it named CONTAINER1 CREATE OBJECT g_custom_container1 EXPORTING container_name = 'CONTAINER1'. IF sy-subrc <> 0. MESSAGE x208(00) WITH 'ERROR'(100). ENDIF. *&---------------------------------------------------------------------* *9.create a instance for cl_gui_alv_grid class,an object named l_alv *&---------------------------------------------------------------------* * create gird control CREATE OBJECT l_alv EXPORTING i_parent = g_custom_container1. IF sy-subrc <> 0. MESSAGE x208(00) WITH 'ERROR'. ENDIF. *&---------------------------------------------------------------------* ****simple style :no need for container.you can delete step 2&8,then ****change step 9 like this: ****create object l_alv exporting i_parent = cl_gui_container=>screen0. *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *10.Create fieldcatalog internal table *&---------------------------------------------------------------------* it_fieldcatalog-fieldname = 'CARRID'. it_fieldcatalog-ref_field = 'CARRID '. it_fieldcatalog-ref_table = 'SFLIGHT'. it_fieldcatalog-coltext = 'Airline Code'. it_fieldcatalog-col_pos = 1. it_fieldcatalog-outputlen = '10'. APPEND it_fieldcatalog TO gt_fieldcatalog. *&---------------------------------------------------------------------* *11.Create layout title.---not necessary *&---------------------------------------------------------------------* gs_layout-grid_title = 'Display flights'. gs_layout-cwidth_opt = 'X'. *&---------------------------------------------------------------------* *11.Call screen. *&---------------------------------------------------------------------* CALL SCREEN 100. *&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE status_0100 OUTPUT. SET PF-STATUS 'GUISTATUS'. SET TITLEBAR 'GUITITLE'. CALL METHOD l_alv->set_table_for_first_display EXPORTING i_structure_name = 'SFLIGHT' is_layout = gs_layout CHANGING it_outtab = lt_sflight it_fieldcatalog = gt_fieldcatalog. ENDMODULE. " STATUS_0100 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE user_command_0100 INPUT. save_ok = ok_code. CLEAR ok_code. CASE save_ok. WHEN 'EXIT' OR 'BACK' . LEAVE PROGRAM. ENDCASE.

(0) 评论    (93) 引用   

Subroutine for openning a dialog to select files in SAP

Codes
*&---------------------------------------------------------------------*
*& Form FRM_PC_FILENAME_GET
*&---------------------------------------------------------------------*
* 擖椡僼傽僀儖偺専嶕僿儖僾
*&---------------------------------------------------------------------*
* -->UP_MODE 儌乕僪慖戰:
* 奐偔偺応崌偼乭O乭
* 曐懚偺応崌偼乭S乭
* <--CP_FILENAME 僼傽僀儖柤徧
*----------------------------------------------------------------------*
FORM FRM_PC_FILENAME_GET USING VALUE(UP_MODE) TYPE C
CHANGING VALUE(CP_FILENAME) TYPE RLGRAP-FILENAME.
*亂儘乕僇儖僨乕僞愰尵亃
DATA:
LC_FILE TYPE STRING, "僼傽僀儖柤徧
LC_PATH TYPE STRING, "僼傽僀儖宱楬
LC_FULLPATH TYPE STRING, "弌椡僼傽僀儖柤徧
L_TAB_FILE TYPE FILETABLE, "僼傽僀儖傪堐帩偡傞僥乕僽儖
LSTR_FILE TYPE FILE_TABLE, "僼傽僀儖柤徧傪奿擺偡傞儗僐乕僪
LC_AMOUNT TYPE I. "僼傽僀儖柤徧偺屄悢
IF UP_MODE = CNS_MODE_SAVE.
* 儌乕僪慖戰偼曐懚偺応崌丄僼傽僀儖偺専嶕僿儖僾傪億僢僾傾僢僾
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
CHANGING
FILENAME = LC_FILE "僼傽僀儖柤徧
PATH = LC_PATH "僼傽僀儖宱楬
FULLPATH = LC_FULLPATH "慡僼傽僀儖柤徧
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4.
IF SY-SUBRC = 0.
CP_FILENAME = LC_FULLPATH.
ENDIF.
ELSE.
* 儌乕僪慖戰偼奐偔偺応崌丄僼傽僀儖偺専嶕僿儖僾傪億僢僾傾僢僾
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
CHANGING
FILE_TABLE = L_TAB_FILE "僼傽僀儖僥乕僽儖
RC = LC_AMOUNT "僼傽僀儖柤徧偺屄悢
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
OTHERS = 5.
IF SY-SUBRC = 0.
READ TABLE L_TAB_FILE INTO LSTR_FILE INDEX 1.
CP_FILENAME = LSTR_FILE.
ENDIF.
ENDIF.
ENDFORM. " FRM_PC_FILENAME_GET

(0) 评论    (24) 引用