'ABAP'에 해당되는 글 39건

  1. 2009.11.09 SHIFT l_file BY off PLACES. 1
  2. 2009.11.06 Application server Program.
  3. 2009.11.04 Table Controls: Examples with Modifications
  4. 2009.11.04 Vendor create: Difference between FK01 and XK01
  5. 2009.11.04 Using SAP List Viewer (ALV) for List Display
  6. 2009.11.04 ABAP and Unicode
  7. 2009.11.04 Character Codes 1
  8. 2009.10.28 Plant Maintenance Customer Service Workflow Scenario
  9. 2009.07.10 ABAP Code Sample For Reporting With Smart Forms
  10. 2009.07.10 BAPI_PO_CHANGE test 1

SHIFT l_file BY off PLACES.

|


REPORT  YRTEST00007.

  data: l_file(17).

  data: off  TYPE i,
        l_a(4) type n.

*----------------------------------------------------------------------*
end-of-SELECTION.
*----------------------------------------------------------------------*
  l_file = 'BI20100101C000001'.

  off = 13.
  SHIFT l_file BY off PLACES.

  write: l_file.

  l_a = l_file + 1.

  write: / l_a.




And

Application server Program.

|

Upload / Download / Delete functionality of Application server Program.

*&---------------------------------------------------------------------*
*& Report ZAPPLSERVER *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT ZAPPLSERVER message-id FB.
************************************************************************
* Constants
constants :c_mask(80) type c value ',.,..', " Mask

c_file_type(10) type c value 'ASC', " File type

c_mode(1) type c value 'L'. " Mode

* Internal tables *

data: begin of i_file occurs 0,

field(3000) type c,

end of i_file.

data :

v_msg(100),

struct_file like i_file occurs 0.

* Parameters

parameters: p_fpath type draw-filep obligatory,

p_lpath type localfile,

p_upload as checkbox default 'X',

p_dload as checkbox,

p_delete as checkbox.

************************************************************************

* Check selection-screen entries *

************************************************************************

* At selection screen

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_lpath.

PERFORM get_file CHANGING p_lpath.

************************************************************************

* Main *

************************************************************************

* Start of selection

start-of-selection.

if p_upload = 'X'.

* Upload to app server

perform upload_to_appserver.

endif.

if p_dload = 'X'.

* Download to desktop

perform download_to_desktop.

endif.

if p_delete = 'X'.

* Delete file on app server

delete dataset p_fpath.

if sy-subrc = 0.

message s000 with 'File deleted'.

endif.

endif.

************************************************************************

* OUTPUT of extracted data *

************************************************************************

* sort.

* loop.

*

* endloop.

************************************************************************

* EVENTS DURING LISTPROCESSING *

************************************************************************

************************************************************************

* EVENTS AT USER COMMAND

************************************************************************

*at line selection.

*at user-command.

************************************************************************

* ROUTINES/FORM *

************************************************************************

*-------------------------------------------------------------

* Set file path of local machine

*-------------------------------------------------------------

FORM get_file CHANGING file_out.

DATA: l_filename TYPE localfile. "Local file for upload/download

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

mask = c_mask

mode = c_mode

IMPORTING

filename = l_filename

EXCEPTIONS

inv_winsys = 01

no_batch = 02

selection_cancel = 03

selection_error = 04.

p_lpath = l_filename.

ENDFORM.

*&---------------------------------------------------------------------*

*& Form UPLOAD_TO_APPSERVER

*&---------------------------------------------------------------------*

* Upload local file to app server

*----------------------------------------------------------------------*

form upload_to_appserver .

data: l_lpath type string.

l_lpath = p_lpath.

refresh i_file.

clear i_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = l_lpath

FILETYPE = c_file_type

* HAS_FIELD_SEPARATOR = ' '

* HEADER_LENGTH = 0

* READ_BY_LINE = 'X'

* DAT_MODE = 'X'

* CODEPAGE = ' '

* IGNORE_CERR = ABAP_TRUE

* REPLACEMENT = SPACE

* CHECK_BOM = '#'

* IMPORTING

* FILELENGTH =

* HEADER =

TABLES

DATA_TAB = i_file

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17.

open dataset p_fpath for output in text mode encoding default

message v_msg.

if sy-subrc = 0.

loop at i_file. " into struct_file.

if not i_file is initial.

transfer i_file to p_fpath.

endif.

endloop.

else.

message e000 with 'File cannot be opened for output'.

endif.

close dataset p_fpath.

endform. " UPLOAD_TO_APPSERVER

*&---------------------------------------------------------------------*

*& Form DOWNLOAD_TO_DESKTOP

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

form download_to_desktop .

open dataset p_fpath for input in text mode

encoding default

message v_msg.

if sy-subrc = 0.

refresh : i_file.

do.

read dataset p_fpath into i_file.

if sy-subrc = 0.

append i_file to i_file.

else.

exit.

endif.

enddo.

else.

message e000 with 'File cannot be opened'.

endif.

close dataset p_fpath.

call function 'DOWNLOAD'

exporting

filename = p_lpath

tables

data_tab = i_file.

endform. " DOWNLOAD_TO_DESKTOP
 
And

Table Controls: Examples with Modifications

|


 Table Controls: Examples with Modifications 

The following example processes a table control with LOOP with parallel loop using an internal table. By using function codes you can sort columns and delete rows from the internal table. The ready for input status of the table control fields is controlled using a function code.

 

REPORT demo_dynpro_tabcont_loop_at.

CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.
DATA: cols LIKE LINE OF flights-cols,
lines TYPE i.

DATA: ok_code TYPE sy-ucomm,
      save_ok TYPE sy-ucomm.

DATA: itab TYPE TABLE OF demo_conn.

      TABLES demo_conn.

SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.

LOOP AT flights-cols INTO cols WHERE index GT 2.
  cols-screen-input = '0'.
  MODIFY flights-cols FROM cols INDEX sy-tabix.
ENDLOOP.

CALL SCREEN 100.

MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SCREEN_100'.
DESCRIBE TABLE itab LINES lines.
flights-lines = lines.
ENDMODULE.

MODULE cancel INPUT.
  LEAVE PROGRAM.
ENDMODULE.

MODULE read_table_control INPUT.
  MODIFY itab FROM demo_conn INDEX flights-current_line.
ENDMODULE.

MODULE user_command_0100 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'TOGGLE'.
      LOOP AT flights-cols INTO cols WHERE index GT 2.
        IF  cols-screen-input = '0'.
          cols-screen-input = '1'.
        ELSEIF  cols-screen-input = '1'.
          cols-screen-input = '0'.
      ENDIF.
  MODIFY flights-cols FROM cols INDEX sy-tabix.
ENDLOOP.
    WHEN 'SORT_UP'.
      READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.
      IF sy-subrc = 0.
        SORT itab STABLE BY (cols-screen-name+10) ASCENDING.
        cols-selected = ' '.
  MODIFY flights-cols FROM cols INDEX sy-tabix.
      ENDIF.
    WHEN 'SORT_DOWN'.
      READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.
      IF sy-subrc = 0.
        SORT itab STABLE BY (cols-screen-name+10) DESCENDING.
        cols-selected = ' '.
  MODIFY flights-cols FROM cols INDEX sy-tabix.
      ENDIF.
    WHEN 'DELETE'.
      READ TABLE flights-cols INTO cols
                              WITH KEY screen-input = '1'.
      IF sy-subrc = 0.
        LOOP AT itab INTO demo_conn WHERE mark = 'X'.
          DELETE itab.
ENDLOOP.
      ENDIF.
ENDCASE.
ENDMODULE.

The layout of screen 100 is:

A resizable table control called FLIGHTS is defined. The fields of the table control are transferred from the structure DEMO_CONN in the ABAP Dictionary. The first two columns are lead columns. The corresponding fields are output fields. A title bar, columns headers, and a selection column are created. The component MARK of type character with length 1 from structure DEMO_CONN is assigned to the selection column. You can select one column and several lines.

It has the following flow logic:

PROCESS BEFORE OUTPUT.
  MODULE status_0100.
  LOOP AT itab INTO demo_conn WITH CONTROL flights.
ENDLOOP.

PROCESS AFTER INPUT.
  MODULE cancel AT EXIT-COMMAND.
  LOOP AT itab.
    MODULE read_table_control.
ENDLOOP.
  MODULE user_command_0100.

A loop is executed at PBO and PAI using the table control FLIGHTS and is also executed using the internal table ITAB of the ABAP program. During the PBO loop, no module is called to fill the table control from table ITAB of the ABAP program. However, during the PAI loop, a module is called to modify table ITAB.

At PBO the component LINES of control structure FLIGHTS is filled explicitly with the current number of rows of the internal table before the PBO loop to install the scroll bar of the table control.

During the PBO loop, in the module FILL_TABLE_CONTROL the work area DEMO_CONN is filled with values from the internal table, where the row index corresponds to the current row of the table control.

During the PAI loop, the rows of the internal table, whose row index corresponds to the current row of the table control, are overwritten with the contents of the work area DEMO_CONN. User input is transferred from the input fields of the control to the internal table. In particular, the internal table also contains a flag in the column MARK to indicate whether the row of the table control is selected or not.

After the PAI loop, user input is processed in the module USER_COMMAND. The GUI status SCREEN_100 provides the appropriate function codes.

When the program is called not all of the fields in the table control are ready for input. The static specifications of the table control in the Screen Painter are modified before CALL SCREEN in the program. The system uses the table COLS in control structure FLIGHTS. All columns with a column position larger than two are set to not ready for input status in a loop using the table FLIGHT-COLS. By choosing the function code TOGGLE, you can change the ready for input status of the columns.

The function codes SORT_UP and SORT_DOWN allow you to sort selected columns of the internal table ITAB ascending or descending. The static settings of the table control allow you to select only a single column. The selected column is derived from the internal table FLIGHT-COLS. The name of the sort criteria in the SORT statement is determined dynamically from the component COLS-SCREEN-NAME. The prefix DEMO_CONN- must be removed using an offset specification. After sort the selection is undone, and the component SELECTED in table FLIGHT-COLS is assigned a blank character.

You can delete selected rows from the internal table ITAB using the function code DELETE. First the system checks whether the fields of the table control are ready for input. Then all selected rows are deleted in a loop using the internal table ITAB. Since the table control is read again from the internal table in the PBO loop, the rows on the screen are deleted.

 

And

Vendor create: Difference between FK01 and XK01

|


The difference between xk01 and fk01 is

XK01 is used to create vendor centrally.
fk01 is used to create vendor financialy.


you should keep in mind that Purchasing info is
stored at the Purchasing Organization level, and Sales data is stored at the
Sales Area level - neither of those two classes of data are stored at the
Company Code level. This is what a previous respondent wrote (you even
quoted it in your response), but your answer contradicted it.


A vendor master and customer master has 3 segments: the general data
segment, the company code segment and the purchasing organization or
sales organization segment. When you create the vendor / customer
centrally you create all 3 segments, whereas when you create the
vendor / customer using FK01 / FD01 you only create the general data
segment and the company code segment.

>>ref -> http://sap.ittoolbox.com/groups/technical-functional/sap-acct/difference-between-xk01-fk01-2590408




And

Using SAP List Viewer (ALV) for List Display

|


And

ABAP and Unicode

|


ABAP and Unicode 

From Release 6.10, ABAP supports multi-byte coding for characters in Unicode. Prior to Release 6.10, ABAP used only character sets that were based on single-byte codes ? such as ASCII and EBCDIC ? or double-byte codes, such as SJIS and BIG5.

This switch to Unicode affects all statements where an explicit or implicit assumption is made about the internal length of a character. If you use these statements in a program that is designed to exploit the Unicode capabilities of the runtime environment, they must be checked and changed if necessary. Once a Unicode-enabled program has been changed accordingly, it behaves in the same way in both Unicode and non-Unicode systems. You can develop programs in a non-Unicode system (NUS) and then import them into a Unicode system (US). The following sections describe the conversions that are necessary:

 

Character Codes

ABAP Development Under Unicode

Concepts and Conventions

Restrictions in Unicode Programs

New ABAP Statements for Unicode

New Classes for Unicode

RFC and Unicode

Other Measures

Other Sample Programs

Unicode Glossary

 

ABAP Development Under Unicode 

A Unicode-enabled ABAP program (UP) is a program in which all Unicode checks are effective. Such a program returns the same results in a non-Unicode system (NUS) as in a Unicode system (US). In order to perform the relevant syntax checks, you must activate the Unicode flag in the screens of the program and class attributes.

In a US, you can only execute programs for which the Unicode flag is set. In future, the Unicode flag must be set for all SAP programs to enable them to run on a US. If the Unicode flag is set for a program, the syntax is checked and the program executed according to the rules described in this document, regardless of whether the system is a US or an NUS. From now on, the Unicode flag must be set for all new programs and classes that are created.

If the Unicode flag is not set, a program can only be executed in an NUS. The syntactical and semantic changes described below do not apply to such programs. However, you can use all language extensions that have been introduced in the process of the conversion to Unicode.

As a result of the modifications and restrictions associated with the Unicode flag, programs are executed in both Unicode and non-Unicode systems with the same semantics to a large degree. In rare cases, however, differences may occur. Programs that are designed to run on both systems therefore need to be tested on both platforms.

You are recommended to follow the procedure below to make your programs US-compliant:

  • The UNICODE task in transaction SAMT performs first an NUS and then a US syntax check for a selected program set. For an overview of the syntax errors by systems, programs and authors, consult the following document in SAPNet: Alternatively, you can start the ABAP program RSUNISCAN_FINAL to determine the Unicode-relevant syntax errors for a single program.
  • Before you can set the Unicode flag in the NUS in the attributes of the program concerned, all syntax errors must be removed.
  • Having enabled the Unicode flag in the NUS, you can run the syntax check for this program. To display a maximum of 50 syntax errors simultaneously, choose Utilities -> Settings -> Editor in the ABAP Editor and select the corresponding checkbox.
  • Once all syntactical requirements are met in the NUS, you must test the program both in the NUS and US. The purpose of this test is to recognize any runtime errors and make sure that the results are correct in both systems. To rule out runtime errors in advance, you should always type field symbols and parameters so that any potential problems can be detected during the syntax check.

And

Character Codes

|


Character Codes 

In the past, SAP developers used various codes to encode characters of different alphabets, for example, ASCII, EBCDI, or double-byte code pages.

  • ASCII (American Standard Code for Information Interchange) encodes each character using 1 byte = 8 bit. This makes it possible to represent a maximum of 28 = 256 characters to which the combinations [00000000, 11111111] are assigned. Common code pages are, for example, ISO88591 for West European or ISO88595 for Cyrillic fonts.
  • EBCDI (Extended Binary Coded Decimal Interchange) also uses 1 byte to encode each character, which again makes it possible to represent 256 characters. EBCDIC 0697/0500 is an old IBM format that is used on AS/400 machines for West European fonts, for example.
  • Double-byte code pages require 1 or 2 bytes for each character. This allows you to form 216 = 65536 combinations where usually only 10,000 - 15,000 characters are used. Double-byte code pages are, for example, SJIS for Japanese and BIG5 for traditional Chinese.

Using these character sets, you can account for each language relevant to the SAP System. However, problems occur if you want to merge texts from different incompatible character sets in a central system. Equally, exchanging data between systems with incompatible character sets can result in unprecedented situations.

One solution to this problem is to use a code comprising all characters used on earth. This code is called Unicode (ISO/IEC 10646) and consists of at least 16 bit = 2 bytes, alternatively of 32 bit = 4 bytes per character. Although the conversion effort for the R/3 kernel and applications is considerable, the migration to Unicode provides great benefits in the long run:

  • The Internet and consequently also mySAP.com are entirely based on Unicode, which thus is a basic requirement for international competitiveness.
  • Unicode allows all R/3 users to install a central R/3 System that covers all business processes worldwide.
  • Companies using different distributed systems frequently want to aggregate their worldwide corporate data. Without Unicode, they would be able to do this only to a limited degree.
  • With Unicode, you can use multiple languages simultaneously at a single frontend computer.
  • Unicode is required for cross-application data exchange without loss of data due to incompatible character sets. One way to present documents in the World Wide Web (www) is XML, for example.

ABAP programs must be modified wherever an explicit or implicit assumption is made with regard to the internal length of a character. As a result, a new level of abstraction is reached which makes it possible to run one and the same program both in conventional and in Unicode systems. In addition, if new characters are added to the Unicode character set, SAP can decide whether to represent these characters internally using 2 or 4 bytes.

 

The examples presented in the following sections are based on a Unicode encoding using 2 bytes per character.

And

Plant Maintenance Customer Service Workflow Scenario

|


And

ABAP Code Sample For Reporting With Smart Forms

|
And

BAPI_PO_CHANGE test

|


*&---------------------------------------------------------------------*
*& Report  ZTESTCYKIM8000
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

report  ztestcykim8000.

  data: lt_CMMDA like table of CMMDA with header line,
        ls_cmmda like cmmda.

  lt_CMMDA-EBELN = '5000003719'.
  lt_CMMDA-EBELP = '10'.
  append lt_cmmda.

data: lt_RETURN like TABLE OF BAPIRET2 WITH HEADER LINE,
      lt_POITEM like TABLE OF BAPIMEPOITEM WITH HEADER LINE,
      lt_POITEMX like TABLE OF BAPIMEPOITEMX WITH HEADER LINE.


refresh: lt_poitem, lt_poitemx.

lt_poitem-PO_ITEM = '10'.
lt_poitem-customer = '0001100122'.
append lt_poitem.

lt_poitemx-po_item = '10'.
lt_poitemx-customer = 'X'.
append lt_poitemx.

call function 'BAPI_PO_CHANGE'
  exporting
    purchaseorder                = '5000003719'
 TABLES
   RETURN                       = lt_return
   POITEM                       = lt_poitem
   POITEMX                      = lt_poitemx.

read table lt_return with key TYPE = 'E'.

if sy-subrc ne 0.
   call function 'BAPI_TRANSACTION_COMMIT'.
   message s303(me) with 'changed'.
else.
  call function 'BAPI_TRANSACTION_ROLLBACK'.
  message s303(me) with 'canceled'.

endif.

*  data: gt_itab like TABLE OF ztmmm65010 with header line.
*
*  select matnr matkl as zprod
*    into CORRESPONDING FIELDS OF TABLE gt_itab
*    from mara
*   where matnr eq 'TEST-KDG2'.
*
*end-of-SELECTION.
*
*  loop at gt_itab.
*    write: / gt_itab-matnr,
*          (20) gt_itab-zprod.
*  endloop.

*    call function 'RKE_GENERATE_ABAP'
*    exporting
**     DEL_LABEL               = ' '
*      erkrs                   =
*      fcode                   =
**     MODEL                   =
*      program                 =
**     PROG_TYPE               = ' '
**     I_DEVCLASS              = 'KEG1'
**     I_GENFLAG               = 'T'
**     I_FIXPT                 = 'X'
**   IMPORTING
**     E_SUBRC                 =
**   EXCEPTIONS
**     DELETE_ERROR            = 1
**     GENERATION_ERROR        = 2
**     MODEL_NOT_FOUND         = 3
**     PROGRAM_NOT_FOUND       = 4
**     ENQUEUE_LOCK            = 5
*     OTHERS                  = 6 .

*  data: gt_itab like table of mara with header line.
*  field-symbols: <wa> type mara.
*  field-symbols: <fs>.
*
*start-of-selection.
*
*  select *
*    into corresponding fields of table gt_itab
*    from mara.
*
*  data: lt_fields like table of rstrucinfo with header line.
*
*  call function 'GET_COMPONENT_LIST'
*    exporting
*      program          = sy-repid
*      fieldname        = 'GT_ITAB'
*    tables
*      components       = lt_fields    .
*
*read table gt_itab index 1.
*data: l_field(50).
*
*loop at lt_fields.
*  concatenate 'GT_ITAB-' lt_fields-compname into l_field.
*  assign (l_field) to <fs>.
*  if <fs> is initial.
*    write: / lt_fields-compname.
*  else.
**    write: / <fs>.
*  endif.
*endloop.



*  loop at gt_itab assigning <wa>.
*    if <wa>-matnr < '10000000'.
*      write: / <wa>-matnr.
*
*    endif.
*
*  endloop.

*  call function 'RKE_GENERATE_ABAP'
*    exporting
**     DEL_LABEL               = ' '
*      erkrs                   =
*      fcode                   =
**     MODEL                   =
*      program                 =
**     PROG_TYPE               = ' '
**     I_DEVCLASS              = 'KEG1'
**     I_GENFLAG               = 'T'
**     I_FIXPT                 = 'X'
**   IMPORTING
**     E_SUBRC                 =
**   EXCEPTIONS
**     DELETE_ERROR            = 1
**     GENERATION_ERROR        = 2
**     MODEL_NOT_FOUND         = 3
**     PROGRAM_NOT_FOUND       = 4
**     ENQUEUE_LOCK            = 5
*     OTHERS                  = 6 .


*Messages
*----------------------------------------------------------
*
* Message class: ME
*303   & & & &

 
And
prev | 1 | 2 | 3 | 4 | next