Common Questions and Answers about ABAP/4 and Developments

简介:

1. What is the difference between external & internal subroutine?

2. Why do we use ALV?

3. Why do we use GET CURSOR and what is it?

4. Both the events AT SELECTION-SCREEN and AT USER-COMMAND are processed after user input.  
    Then what is the difference between these and when we should use what? 

Sudeshna

Answer 1: 
1) Internal subroutines in the sense ..subroutines which are defined and used in a same program...external in the sense if you create a sub routine in one program and you're calling this subroutine in another program ..then this is external subroutine.

2) ALV gives many advantages than a list like sorting summing getting graphics like that stuff

3) While generating a interactive report we will use get cursor..use is to get the value of the fiel under the cursor..

4) At selection screen is used to validate the fields in a selection screen...and at user command  is used to modify the screen in a selection screen and in genarating secondary lists..

Sarath Reddy

Answer 2: 
1. The name itself implies the internal subroutines defined by form /perform.. can be called within the same prog in which they were declared.....external subroutines can be called outside the program.......

2. SAP LIST VIEWER is ALV  . its main advantage is by using ALV technique we can find totals ,subtotals ,sort in any order etc there itself in the list output of course we need to write all those functionalities  while using ALV...also many functional modules are defined under ALV concept...

3. GETCURSOR is used to trace the position of the cursor in the list ..  
suppose we want to double click on any filled in the list and want to trace data using that field we use getcursor .....

4.AT SELECTION-SCREEN  is used where you have a seperate selection screen using select-options or parameters where as AT USER-COMMAND is used where no selection screen  exists....at.user-command  is mainly used while setting pf-status which means creating our own menu with function codes etc...

Shiva

I had seen some of the standard abap that the table name had *, like *ekpo. What is the meaning? What is the difference between with * and without * ? 

It just lets you use the table a second time. For example: 

select single * from ekpo where ebeln = '12345' and ebelp = '1'. 

select single * from *ekpo where ebeln = '67890' and ebelp = '1'. 

You now have two separate records, one in ekpo and one in *ekpo. 

Another way to do this is to simply use the 'into' argument in the 'select' statement to read the second ekpo record into some other field. The '*' format can be confusing, I think it may be left over from earlier releases, like 2.2.

EKPO is database table and *EKPO is internal table.

Once you select into EKPO, you can use it the same way as *EKPO. 
 

How do I use variables in the FORMAT command?

DATA COLORID TYPE I VALUE 4. 
FORMAT INTENSIFIED ON COLOR = COLORID. 
 

When using CALL 'SYSTEM' id 'COMMAND' field unix-command, how does one capture the results of the command? For example, if the unix-command were the date?

You capture the results in the table e.g TABL, like this  
DATA: BEGIN OF TABL OCCURS 0, 
        LINE(560), 
      END OF TABL.

REFRESH TABL. 
CALL 'SYSTEM' ID 'COMMAND' FIELD PARCOM_LOC 
ID 'TAB' FIELD TABL-*SYS*.  
 

I am working on a program that needs to show number of days between 2 dates. When I scanned the function library, I only found a function to give you the number of years between dates. I can probably code this in ABAP but does anyone know if a function exists to do this.

I wrote this example for you. I think this is what you need.

DATA: DATE_1 LIKE SY-DATUM,  
             DATE_2 LIKE SY-DATUM. 
             DATA DAYS TYPE I.

DATE_1 = SY-DATUM. 
DATE_2 = SY-DATUM + 65. 
DAYS = DATE_2 - DATE_1. 
WRITE:/ 'DATE_2=',DATE_2,'DATE_1=',DATE_1,'DAYS=',DAYS.

Run this code and then you will understand.  
 

How do I concatenate two strings in Abap/4? 

For all SAP Versions  
STR_LENGTH = STRLEN( STRING1 ). 
MOVE STRING1 TO STRING3. 
WRITE STRING2 TO STRING3+STR_LENGTH.

For SAP Version 3.0 choose:

CONCATENATE STRING1 STRING2 INTO STRING3.

If you want a space between both fields:

CONCATENATE STRING1 STRING2 INTO STRING3 SEPARATED BY ' '.

For SAP Version 2.2 choose Functions:

STRING_CONCATENATE for 2 Strings and 
STRING_CONCATENATE_3 for 3 Strings.  
 

Has anyone been successful in suppressing the selection screen that is automatically displayed when using logical data bases. I want to run a job in the background using a logical database and I do not want the user prompted for the parameters. I want to pass the parameters in the program.

Try using the SUBMIT rep USING SELECTION-SET 'variant' WITH .... 
command in the report to pass the variant thru the program 
 

I would like to know how to execute from ABAP code an external Unix program and check for a return code? 

There are different ways to this:

(1) OPEN DATASET <file> FOR OUTPUT 'unix command' 
CLOSE DATASET <file> 
This command executes the unix command and writes the output into <file> 
Look into OSS Note 9391.

(2) or try the following program but unfortunately the command CALL SYSTEM is 
not supported by SAP. If you are on R/3 2.1 - 2.2x you can get some idea's from the program SAPMSOS0.

REPORT ZUNIXCOM .

DATA: U_COMMAND(200). 
* Table for system messages 
DATA: BEGIN OF RT OCCURS 100 , 
LINE(100) , 
END OF RT .

START-OF-SELECTION .

MOVE 'unix command' to U_COMMAND . 
REFRESH RT. 
CALL 'SYSTEM' ID 'COMMAND' FIELD U_COMMAND 
ID 'TAB' FIELD RT-*SYS* . 
LOOP AT RT. 
WRITE : / RT-LINE . 
ENDLOOP. 

专注于企业信息化,最近对股票数据分析较为感兴趣,可免费分享股票个股主力资金实时变化趋势分析工具,股票交流QQ群:457394862

本文转自沧海-重庆博客园博客,原文链接:http://www.cnblogs.com/omygod/archive/2007/12/16/996998.html,如需转载请自行联系原作者
目录
相关文章
|
8月前
|
程序员
开发语言漫谈-ABAP
ABAP是SAP公司专门用于SAP软件环境的专门语言
|
SQL 设计模式 前端开发
【置顶】SAP ABAP开发实战——从入门到精通系列目录
本文章为SAP ABAP开发实战——从入门到精通系列的目录以及关于该教程的后续写作计划表
1753 0
【置顶】SAP ABAP开发实战——从入门到精通系列目录
|
BI
SAP ABAP在线预览文档对象的开发实现
应用场景:有些定制化开发(报表/功能增强等)完成之后,客户需要将其操作手册或者相关文档放在某个报表的初始画面,供实际操作者在线查阅,当然这个功能也同样类似于模板的下载,这里就以在线预览(直接打开)为例进行说明。
243 0
|
前端开发 JavaScript 数据库
如何使用 Restful ABAP Programming 编程模型开发一个支持增删改查的 Fiori 应用(二)
Restful ABAP Programming 编程模式是 ABAP 这门编程语言在不断向前进化的过程中,诞生的一门新的编程模型,简称为RAP模型。
168 0
如何使用 Restful ABAP Programming 编程模型开发一个支持增删改查的 Fiori 应用(二)
|
程序员 BI
也谈SAP业务顾问如何避免被ABAP开发顾问怒打
也谈SAP业务顾问如何避免被ABAP开发顾问怒打
也谈SAP业务顾问如何避免被ABAP开发顾问怒打
abap开发function module时使用tables传递参数报错过时的解决方法
如下图,我写了一个Function Module我要在tables中添加一个参数TABLES参数已过时不管怎么点击保存按钮,一直报错,怎么办呢?不管是不是过时,狂点回车,就保存了
1765 0
|
小程序
ABAP开发基础知识:11)子程序的建立与调用
ABAP子程序(Subrouting)是包含在程序中的一段具有一定功能的代码,能够将某个功能作为一个小程序包含在主程序中,以方便程序分析及阅读。特别是一此程序中多次用到的功能,可以简化代码,增加程序的可读性且便于维护。
1499 0
|
索引 机器学习/深度学习
ABAP开发基础知识:12)ABAP宏的应用
宏(Macros)是一段独立的代码,能实现数据的运算与输出,功能与子程序类似,主要应用于同一程序中某些重复的运算,以简化代码,其定义语法如下:        DEFINE INCREMENT.    "INCREMENT为自定义宏的名称。
936 0
ABAP开发基础知识:9)字符串控制函数
本篇文章主要介绍ABAP编程中字符串的控制与操作,好了废活说多了也没用,开始吧。        1)CONCATENATE:实现字符串的合并。        基本语法:        CONCATENATE  f1.
1240 0