Jun 10 2009

BAPI to Copy Materials from one Plant to Another

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
*
* Copy Materials from one Plant to Another
* First run   GETDATA AS CHECKBOX, "Tick to download materials data to local harddisk
* Second run  UPDDATA AS CHECKBOX. "Tick to update date to Materials Master
* Check data in Excel before Second run
* 
REPORT ZBAPIMM01 LINE-SIZE 255 NO STANDARD PAGE HEADING
                 LINE-COUNT 065(001).
 
TABLES: T001L, "Storage Locations
        MARA,  "General Material Data
        MAKT,  "Material Descriptions
        MBEW,  "Material Valuation
        MARC.  "Plant Data for Material
 
DATA: BAPI_HEAD   LIKE BAPIMATHEAD,
      BAPI_MAKT   LIKE BAPI_MAKT,    "Material Description
      BAPI_MARA1  LIKE BAPI_MARA,    "Client Data
      BAPI_MARAX  LIKE BAPI_MARAX,
      BAPI_MARC1  LIKE BAPI_MARC,    "Plant View
      BAPI_MARCX  LIKE BAPI_MARCX,
      BAPI_MBEW1  LIKE BAPI_MBEW,    "Accounting View
      BAPI_MBEWX  LIKE BAPI_MBEWX,
      BAPI_RETURN LIKE BAPIRET2.
 
DATA: BEGIN OF INT_MAKT OCCURS 100.
        INCLUDE STRUCTURE BAPI_MAKT.
DATA: END OF INT_MAKT.
 
DATA: BEGIN OF INT_MAT OCCURS 100,
         WERKS(4),     "Plant
         MTART(4),     "Material type
         MATNR(18),    "Material number
         MATKL(9) ,    "Material group
         MBRSH(1),     "Industry sector
         MEINS(3),     "Base unit of measure
         GEWEI(3),     "Weight Unit
         SPART(2),     "Division
         EKGRP(3),     "Purchasing group
         VPRSV(1),     "Price control indicator
         STPRS(12),    "Standard price
         PEINH(3),     "Price unit
         SPRAS(2),     "Language key
         MAKTX(40),     "Material description
       END OF INT_MAT.
 
SELECT-OPTIONS:
            PLANT    FOR  MARC-WERKS OBLIGATORY MEMORY ID PLT,
            MATERIAL FOR  MARA-MATNR MEMORY ID MAT,
            MATLTYPE FOR  MARA-MTART MEMORY ID MTY,
            DIVISION FOR  MARA-SPART MEMORY ID DIV.
PARAMETERS:  F_FILE LIKE RLGRAP-FILENAME
             DEFAULT 'C:\DATA\ZMATERIAL.XLS' MEMORY ID F_FILE,
             GETDATA AS CHECKBOX, "Tick to download materials data to local harddisk
             UPDDATA AS CHECKBOX. "Tick to update date to Materials Master
 
IF GETDATA = 'X'.
   PERFORM DOWNLOAD_DATA.
   PERFORM DOWNLOAD_FILE.
ENDIF.
IF UPDDATA = 'X'.
   PERFORM UPLOAD_FILE.
   PERFORM UPDATE_MM.
ENDIF.
 
FORM DOWNLOAD_DATA.
SELECT * FROM MARC  WHERE LVORM EQ ' '
                      AND WERKS IN PLANT
                      AND MATNR IN MATERIAL.
    CLEAR MARA.
    SELECT SINGLE * FROM MARA WHERE MATNR =  MARC-MATNR.
    CHECK MATLTYPE.
    CHECK DIVISION.
 
    CLEAR MBEW.
    SELECT SINGLE * FROM MBEW WHERE MATNR =  MARC-MATNR
                                AND BWKEY =  MARC-WERKS.
 
    CLEAR MAKT.
    SELECT SINGLE * FROM MAKT WHERE SPRAS =  'EN'
                                AND MATNR =  MARC-MATNR.
 
    WRITE:/ MARC-WERKS,    "Plant
            MARA-MTART,    "Material type
            MARA-MATNR,    "Material number
            MARA-MATKL,    "Material group
            MARA-MBRSH,    "Industry sector
            MARA-MEINS,    "Base unit of measure
            MARA-GEWEI,    "Weight Unit
            MARA-SPART,    "Division
            MARC-EKGRP,    "Purchasing group
            MBEW-VPRSV,    "Price control indicator
            MBEW-STPRS,    "Standard price
            MBEW-PEINH,    "Price unit
            MAKT-SPRAS,    "Language key
            MAKT-MAKTX.    "Material description
 
            INT_MAT-WERKS = MARC-WERKS.    "Plant
            INT_MAT-MTART = MARA-MTART.    "Material type
            INT_MAT-MATNR = MARA-MATNR.    "Material number
            INT_MAT-MATKL = MARA-MATKL.    "Material group
            INT_MAT-MBRSH = MARA-MBRSH.    "Industry sector
            INT_MAT-MEINS = MARA-MEINS.    "Base unit of measure
            INT_MAT-GEWEI = MARA-GEWEI.    "Weight Unit
            INT_MAT-SPART = MARA-SPART.    "Division
            INT_MAT-EKGRP = MARC-EKGRP.    "Purchasing group
            INT_MAT-VPRSV = MBEW-VPRSV.    "Price control indicator
            INT_MAT-STPRS = MBEW-STPRS.    "Standard price
            INT_MAT-PEINH = MBEW-PEINH.    "Price unit
            INT_MAT-SPRAS = MAKT-SPRAS.    "Language key
            INT_MAT-MAKTX = MAKT-MAKTX.    "Material description
 
            APPEND INT_MAT.
            CLEAR  INT_MAT.
ENDSELECT.
ENDFORM.
 
FORM DOWNLOAD_FILE.
call function 'WS_DOWNLOAD'
  EXPORTING
    FILENAME                      = F_FILE
    FILETYPE                      = 'DAT'
*   FILETYPE                      = 'WK1'
  tables
    data_tab                      = INT_MAT
  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
    OTHERS                        = 10.
 
IF SY-SUBRC = 0.
   FORMAT COLOR COL_GROUP.
   WRITE:/ 'Data Download Successfully to your local harddisk'.
   SKIP.
ENDIF.
ENDFORM.
 
FORM UPLOAD_FILE.
call function 'WS_UPLOAD'
  EXPORTING
    FILENAME                      = F_FILE
    FILETYPE                      = 'DAT'
*   FILETYPE                      = 'WK1'
  tables
    data_tab                      = INT_MAT
  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
    OTHERS                        = 10.
 
IF SY-SUBRC = 0.
   FORMAT COLOR COL_GROUP.
   WRITE:/ 'Data Upload Successfully from your local harddisk'.
   SKIP.
ENDIF.
ENDFORM.
 
FORM UPDATE_MM.
LOOP AT INT_MAT.
* Header
    BAPI_HEAD-MATERIAL        = INT_MAT-MATNR.
    BAPI_HEAD-IND_SECTOR      = INT_MAT-MBRSH.
    BAPI_HEAD-MATL_TYPE       = INT_MAT-MTART.
    BAPI_HEAD-BASIC_VIEW      = 'X'.
    BAPI_HEAD-PURCHASE_VIEW   = 'X'.
    BAPI_HEAD-ACCOUNT_VIEW    = 'X'.
* Material Description
    REFRESH INT_MAKT.
    INT_MAKT-LANGU           = INT_MAT-SPRAS.
    INT_MAKT-MATL_DESC       = INT_MAT-MAKTX.
    APPEND INT_MAKT.
* Client Data - Basic
    BAPI_MARA1-MATL_GROUP     = INT_MAT-MATKL.
    BAPI_MARA1-BASE_UOM       = INT_MAT-MEINS.
    BAPI_MARA1-UNIT_OF_WT     = INT_MAT-GEWEI.
    BAPI_MARA1-DIVISION       = INT_MAT-SPART.
 
    BAPI_MARAX-MATL_GROUP = 'X'.
    BAPI_MARAX-BASE_UOM   = 'X'.
    BAPI_MARAX-UNIT_OF_WT = 'X'.
    BAPI_MARAX-DIVISION   = 'X'.
* Plant - Purchasing
    BAPI_MARC1-PLANT      = INT_MAT-WERKS.
    BAPI_MARC1-PUR_GROUP  = INT_MAT-EKGRP.
 
    BAPI_MARCX-PLANT      = INT_MAT-WERKS.
    BAPI_MARCX-PUR_GROUP  = 'X'.
* Accounting
    BAPI_MBEW1-VAL_AREA   = INT_MAT-WERKS.
    BAPI_MBEW1-PRICE_CTRL = INT_MAT-VPRSV.
    BAPI_MBEW1-STD_PRICE  = INT_MAT-STPRS.
    BAPI_MBEW1-PRICE_UNIT = INT_MAT-PEINH.
 
    BAPI_MBEWX-VAL_AREA   = INT_MAT-WERKS.
    BAPI_MBEWX-PRICE_CTRL = 'X'.
    BAPI_MBEWX-STD_PRICE  = 'X'.
    BAPI_MBEWX-PRICE_UNIT = 'X'.
 
    WRITE:/ BAPI_HEAD, BAPI_MARC1.
 
    call function 'BAPI_MATERIAL_SAVEDATA'
      exporting
        HEADDATA                   = BAPI_HEAD
        CLIENTDATA                 = BAPI_MARA1
        CLIENTDATAX                = BAPI_MARAX
        PLANTDATA                  = BAPI_MARC1
        PLANTDATAX                 = BAPI_MARCX
*       FORECASTPARAMETERS         =
*       FORECASTPARAMETERSX        =
*       PLANNINGDATA               =
*       PLANNINGDATAX              =
*       STORAGELOCATIONDATA        =
*       STORAGELOCATIONDATAX       =
        VALUATIONDATA              = BAPI_MBEW1
        VALUATIONDATAX             = BAPI_MBEWX
*       WAREHOUSENUMBERDATA        =
*       WAREHOUSENUMBERDATAX       =
*       SALESDATA                  = BAPI_MVKE1
*       SALESDATAX                 = BAPI_MVKEX
*       STORAGETYPEDATA            =
*       STORAGETYPEDATAX           =
      IMPORTING
        RETURN                     = BAPI_RETURN
      TABLES
        MATERIALDESCRIPTION        = INT_MAKT
*       UNITSOFMEASURE             =
*       UNITSOFMEASUREX            =
*       INTERNATIONALARTNOS        =
*       MATERIALLONGTEXT           =
*       TAXCLASSIFICATIONS         =
*       RETURNMESSAGES             =
*       PRTDATA                    =
*       PRTDATAX                   =
*       EXTENSIONIN                =
*       EXTENSIONINX               =
          .
 
IF BAPI_RETURN-TYPE = 'E'.
   WRITE:/ 'Error Message ', BAPI_RETURN.
ENDIF.
 
ENDLOOP.
ENDFORM.
*---End of Program

via http://www.sap-img.com/abap/bapi-to-copy-materials-from-one-plant-to-another.htm

TAGS: , ,
Jun 9 2009

SAP ABAP CV SAMPLE & SAP CONSULTANT CV SAMPLE

If you search for SAP ABAP CV sample or SAP consultant CV sample,pls go to below website. I think it’s very useful to you.
http://www.sapdev.co.uk/jobs/cvhome.htm
http://www.portnov.com/FreeResumeSample/SAPresumes.htm

TAGS:
Apr 24 2009

ABAP Program-Upload and download HR photo

Below is ABAP upload and download HR photo program.(via web)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
REPORT  z_barry_hr_photo_upload.
 
DATA: sapobjid LIKE sapb-sapobjid,
      sappfad LIKE sapb-sappfad.
DATA: gd_path TYPE string ,
      filetab TYPE TABLE OF file_info WITH HEADER LINE,
      count TYPE i.
DATA: filename(40) TYPE c ,
      fileext(10) TYPE c ,
      len TYPE i .
 
PARAMETERS: filepath LIKE rlgrap-filename.
 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filepath.
  CALL METHOD cl_gui_frontend_services=>directory_browse
    EXPORTING
      window_title    = 'File Directory'
      initial_folder  = 'C:\'
    CHANGING
      selected_folder = gd_path.
  CALL METHOD cl_gui_cfw=>flush.
  CONCATENATE gd_path '' INTO filepath.
 
START-OF-SELECTION.
  gd_path = filepath .
  CALL METHOD cl_gui_frontend_services=>directory_list_files
    EXPORTING
      directory                   = gd_path
      filter                      = '*.jpg'
    CHANGING
      file_table                  = filetab[]
      count                       = count
    EXCEPTIONS
      cntl_error                  = 1
      directory_list_files_failed = 2
      wrong_parameter             = 3
      error_no_gui                = 4
      not_supported_by_gui        = 5
      OTHERS                      = 6.
 
  LOOP AT filetab.
    SPLIT filetab-filename AT '.' INTO filename fileext.
    len = STRLEN( filename ) .
    IF len <> 8 .
      MESSAGE e000(oo) WITH '文件名长度必须等于8位'.
    ENDIF.
  ENDLOOP.
 
  LOOP AT filetab.
    CONCATENATE gd_path '\' filetab-filename INTO sappfad.
    CONCATENATE filetab-filename+0(8) '0002' INTO sapobjid.
    CALL FUNCTION 'ARCHIV_CREATE_FILE'
      EXPORTING
        ar_object               = 'HRICOLFOTO'
        object_id               = sapobjid
        sap_object              = 'PREL'
        doc_type                = 'JPG'
        path                    = sappfad
      EXCEPTIONS
        error_conectiontable    = 1
        error_parameter         = 2
        error_archiv            = 3
        error_upload            = 4
        error_kernel            = 5
        no_entry_possible       = 6
        error_comunicationtable = 7
        OTHERS                  = 8.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
      WRITE : / 'Upload ',sappfad,'To pernr ',filetab-filename+0(8),'Sccuess!'.
    ENDIF.
  ENDLOOP.
 
 
 
REPORT  z_barry_hr_photo_down.
 
DATA: comps2 TYPE STANDARD TABLE OF scms_doinf WITH HEADER LINE,
      comp_names TYPE STANDARD TABLE OF scms_donam WITH HEADER LINE.
 
PARAMETERS p_pernr LIKE pa0001-pernr.
 
PERFORM photo_down USING p_pernr 'A' '18000101' '99991231' 'D:\abc.jpg'  .
 
*&---------------------------------------------------------------------*
*&      Form  URL_GET
*&---------------------------------------------------------------------*
FORM photo_down USING p_pernr LIKE pernr-pernr
                      p_tclas LIKE pspar-tclas
                      p_begda LIKE prelp-begda
                      p_endda LIKE prelp-endda
                      path TYPE c .
  DATA: l_connect_info LIKE toav0,
        l_exists(1) TYPE c .
  CALL FUNCTION 'HR_IMAGE_EXISTS'
    EXPORTING
      p_pernr        = p_pernr
      p_tclas        = p_tclas
      p_begda        = p_begda
      p_endda        = p_endda
    IMPORTING
      p_exists       = l_exists
      p_connect_info = l_connect_info
    EXCEPTIONS
      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 .
    EXIT.
  ENDIF.
  CALL FUNCTION 'SCMS_DOC_READ_FILES'
    EXPORTING
      stor_cat              = space
      crep_id               = l_connect_info-archiv_id
      doc_id                = l_connect_info-arc_doc_id
      path                  = path
      frontend              = 'X'
    TABLES
      comps                 = comps2
      comp_names            = comp_names
    EXCEPTIONS
      bad_storage_type      = 1
      bad_request           = 2
      unauthorized          = 3
      not_found             = 4
      conflict              = 5
      internal_server_error = 6
      error_http            = 7
      error_signature       = 8
      error_config          = 9
      error_hierarchy       = 10
      error_download        = 11
      error_open            = 12
      error_parameter       = 13
      error                 = 14
      OTHERS                = 15.
  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.                    "photo_down

Apr 16 2009

ABAP interview questions and answers(1)

1. What is an ABAP data dictionary?- ABAP 4 data dictionary describes the logical structures of the objects used in application development and shows how they are mapped to the underlying relational database in tables/views.
2. What are domains and data element?- Domains:Domain is the central object for describing the technical characteristics of an attribute of an business objects. It describes the value range of the field. Data Element: It is used to describe the semantic definition of the table fields like description the field. Data element describes how a field can be displayed to end-user.
3. What is foreign key relationship?- A relationship which can be defined between tables and must be explicitly defined at field level. Foreign keys are used to ensure the consistency of data. Data entered should be checked against existing data to ensure that there are now contradiction. While defining foreign key relationship cardinality has to be specified. Cardinality mentions how many dependent records or how referenced records are possible.

4. Describe data classes.- Master data: It is the data which is seldomly changed. Transaction data: It is the data which is often changed. Organization data: It is a customizing data which is entered in the system when the system is configured and is then rarely changed. System data:It is the data which R/3 system needs for itself.
5. What are indexes?- Indexes are described as a copy of a database table reduced to specific fields. This data exists in sorted form. This sorting form ease fast access to the field of the tables. In order that other fields are also read, a pointer to the associated record of the actual table are included in the index. Yhe indexes are activated along with the table and are created automatically with it in the database.
6. Difference between transparent tables and pooled tables.- Transparent tables: Transparent tables in the dictionary has a one-to-one relation with the table in database. Its structure corresponds to single database field. Table in the database has the same name as in the dictionary. Transparent table holds application data. Pooled tables. Pooled tables in the dictionary has a many-to-one relation with the table in database. Table in the database has the different name as in the dictionary. Pooled table are stored in table pool at the database level.
7. What is an ABAP/4 Query?- ABAP/4 Query is a powerful tool to generate simple reports without any coding. ABAP/4 Query can generate the following 3 simple reports: Basic List: It is the simple reports. Statistics: Reports with statistical functions like Average, Percentages. Ranked Lists: For analytical reports. - For creating a ABAP/4 Query, programmer has to create user group and a functional group. Functional group can be created using with or without logical database table. Finally, assign user group to functional group. Finally, create a query on the functional group generated.
8. What is BDC programming?- Transferring of large/external/legacy data into SAP system using Batch Input programming. Batch input is a automatic procedure referred to as BDC(Batch Data Communications).The central component of the transfer is a queue file which receives the data vie a batch input programs and groups associated data into “sessions”.
9. What are the functional modules used in sequence in BDC?- These are the 3 functional modules which are used in a sequence to perform a data transfer successfully using BDC programming: BDC_OPEN_GROUP - Parameters like Name of the client, sessions and user name are specified in this functional modules. BDC_INSERT - It is used to insert the data for one transaction into a session. BDC_CLOSE_GROUP - This is used to close the batch input session.
10. What are internal tables?- Internal tables are a standard data type object which exists only during the runtime of the program. They are used to perform table calculations on subsets of database tables and for re-organising the contents of database tables according to users need.
11. What is ITS? What are the merits of ITS?- ITS is a Internet Transaction Server. ITS forms an interface between HTTP server and R/3 system, which converts screen provided data by the R/3 system into HTML documents and vice-versa. Merits of ITS: A complete web transaction can be developed and tested in R/3 system. All transaction components, including those used by the ITS outside the R/3 system at runtime, can be stored in the R/3 system. The advantage of automatic language processing in the R/3 system can be utilized to language-dependent HTML documents at runtime.
12. What is DynPro?- DynPro is a Dynamic Programming which is a combination of screen and the associated flow logic Screen is also called as DynPro.
13. What are screen painter and menu painter?- Screen painter: Screen painter is a tool to design and maintain screen and its elements. It allows user to create GUI screens for the transactions. Attributes, layout, filed attributes and flow logic are the elements of Screen painter. Menu painter: Menu painter is a tool to design the interface components. Status, menu bars, menu lists, F-key settings, functions and titles are the components of Menu painters. Screen painter and menu painter both are the graphical interface of an ABAP/4 applications.
14. What are the components of SAP scripts?- SAP scripts is a word processing tool of SAP which has the following components: Standard text. It is like a standard normal documents. Layout sets. - Layout set consists of the following components: Windows and pages, Paragraph formats, Character formats. Creating forms in the R/3 system. Every layout set consists of Header, paragraph, and character string. ABAP/4 program.
15. What is ALV programming in ABAP? When is this grid used in ABAP?- ALV is Application List viewer. Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length. In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain up to 90 columns in the display with the wide array of display options.
16. What are the events in ABAP/4 language?- Initialization, At selection-screen, Start-of-selection, end-of-selection, top-of-page, end-of-page, At line-selection, At user-command, At PF, Get, At New, At LAST, AT END, AT FIRST.
17. What is CTS and what do you know about it?- The Change and Transport System (CTS) is a tool that helps you to organize development projects in the ABAP Workbench and in Customizing, and then transport the changes between the SAP Systems and clients in your system landscape. This documentation provides you with an overview of how to manage changes with the CTS and essential information on setting up your system and client landscape and deciding on a transport strategy. Read and follow this documentation when planning your development project.
18. What are logical databases? What are the advantages/ dis-advantages of logical databases?- To read data from a database tables we use logical database. A logical database provides read-only access to a group of related tables to an ABAP/4 program. Advantages: i)check functions which check that user input is complete, correct,and plausible. ii)Meaningful data selection. iii)central authorization checks for database accesses. iv)good read access performance while retaining the hierarchical data view determined by the application logic. dis advantages: i)If you donot specify a logical database in the program attributes,the GET events never occur. ii)There is no ENDGET command,so the code block associated with an event ends with the next event statement (such as another GET or an END-OF-SELECTION).
19. What is a batch input session?- BATCH INPUT SESSION is an intermediate step between internal table and database table. Data along with the action is stored in session ie data for screen fields, to which screen it is passed, program name behind it, and how next screen is processed.
20. How to upload data using CATT ?- These are the steps to be followed to Upload data through CATT: Creation of the CATT test case & recording the sample data input. Download of the source file template. Modification of the source file. Upload of the data from the source file.
21. What is Smart Forms?- Smart Forms allows you to create forms using a graphical design tool with robust functionality, color, and more. Additionally, all new forms developed at SAP will be created with the new Smart Form solution.
22. How can I make a differentiation between dependent and independent data?- Client dependent or independent transfer requirements include client specific or cross client objects in the change requests. Workbench objects like SAPscripts are client specific, some entries in customizing are client independent. If you display the object list for one change request, and then for each object the object attributes, you will find the flag client specific. If one object in the task list has this flag on, then that transport will be client dependent.
23. What is the difference between macro and subroutine?- Macros can only be used in the program the are defined in and only after the definition are expanded at compilation / generation. Subroutines (FORM) can be called from both the program the are defined in and other programs . A MACRO is more or less an abbreviation for some lines of code that are used more than once or twice. A FORM is a local subroutine (which can be called external). A FUNCTION is (more or less) a subroutine that is called external. Since debugging a MACRO is not really possible, prevent the use of them (I’ve never used them, but seen them in action). If the subroutine is used only local (called internal) use a FORM. If the subroutine is called external (used by more than one program) use a FUNCTION.

TAGS: ,
Apr 16 2009

ABAP ALV Report- SD FLOW ALV

ABAP ALV Report- SD FLOW ALV

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
*&———————————————————————*
*& Report  ZJACKTEST
*&
*&———————————————————————*
*&
*&
*&———————————————————————*
 
REPORT  ZJACKTEST.
 
TYPE-POOLS: slis.
TABLES: vbak,vbap, knvv, kna1, mara ,lips, vbrp.
TYPES: BEGIN OF record,
        sdoc LIKE vbak-vbeln,
        sitem LIKE vbap-posnr,
        mcode LIKE mara-matnr,
        mname LIKE vbap-arktx,
        oquanti LIKE vbap-kwmeng,
        ovalue LIKE vbap-netwr,
        ocurrency LIKE vbap-waerk,
        ddoc LIKE lips-vbeln,
        ditem LIKE lips-posnr,
        idoc LIKE vbrp-vbeln,
        iitem LIKE vbrp-posnr,
      END OF record.
 
DATA: itab TYPE STANDARD TABLE OF record WITH HEADER LINE.
DATA:  name1 LIKE kna1-name1,
       name2 LIKE kna1-name2.
DATA: i_fieldcat_alv TYPE slis_t_fieldcat_alv WITH HEADER LINE,
      it_events TYPE slis_alv_event OCCURS 1 WITH HEADER LINE,
      alv_event        TYPE slis_t_event,
      I_layout TYPE slis_layout_alv,
      i_fieldcat TYPE slis_fieldcat_alv,
      pos        TYPE i VALUE 1,
      w_repid LIKE sy-repid.
*———————————————————————-*
* Selection-screen design                                              *
*———————————————————————-*
 
SELECT-OPTIONS: o_date FOR vbak-erdat OBLIGATORY.     "sales docu date
 
PARAMETERS: customer LIKE vbak-kunnr OBLIGATORY
            DEFAULT ‘GCN00010′,                      "customer code
            material LIKE mara-matnr OBLIGATORY
            DEFAULT ‘000000000280012001′.            "material number
*———————————————————————-*
* Start of selection event                                             *
*———————————————————————-*
 
*START-OF-SELECTION.
 
  PERFORM data_selection.
  perform layout_build.
  PERFORM fields.
  PERFORM append_alv_event CHANGING alv_event.
  PERFORM display_data.
*———————————————————————-*
*form data_selection
**
*———————————————————————-*
 
FORM data_selection.
SELECT a~vbeln b~posnr c~matnr b~arktx b~kwmeng b~netwr b~waerk
        c~vbeln c~posnr d~vbeln d~posnr
INTO (itab-sdoc, itab-sitem, itab-mcode, itab-mname,
       itab-oquanti,itab-ovalue,itab-ocurrency, itab-ddoc,
       itab-ditem, itab-idoc, itab-iitem)
FROM ( ( lips AS c
        INNER JOIN vbrp AS d ON c~vbeln = d~vgbel
                            AND c~posnr = d~vgpos
        INNER JOIN vbap AS b  ON c~vgbel = b~vbeln
                            AND  c~vgpos = b~posnr )
        INNER JOIN vbak AS a ON a~vbeln = b~vbeln )
WHERE a~erdat IN o_date AND a~kunnr = customer AND b~matnr = material.
    APPEND itab.
  ENDSELECT.
 
  IF sy-subrc NE 0.
    MESSAGENo Corresponding Record!TYPEI’.
  ENDIF.
ENDFORM.                    "data_selection
*———————————————————————-*
*form fields
**
*———————————————————————-*
FORM fields.
  REFRESH i_fieldcat_alv.
  pos = 1.
  CLEAR i_fieldcat.
 
  i_fieldcat-col_pos = pos.
  i_fieldcat-fieldname = ‘SDOC’.
  i_fieldcat-seltext_l = ‘주문번호’.
  APPEND i_fieldcat TO i_fieldcat_alv.
 
  pos = pos + 1.
  i_fieldcat-col_pos       =  pos.
  i_fieldcat-fieldname     = ‘SITEM’.
  i_fieldcat-seltext_l     = ‘아이템번호’.
  APPEND i_fieldcat TO  i_fieldcat_alv.
 
  pos = pos + 1.
  i_fieldcat-col_pos       =  pos.
  i_fieldcat-fieldname     = ‘MCODE’.
  i_fieldcat-seltext_l     = ‘제품코드’.
  APPEND i_fieldcat TO  i_fieldcat_alv.
 
  pos = pos + 1.
  i_fieldcat-col_pos       =  pos.
  i_fieldcat-fieldname     = ‘MNAME’.
  i_fieldcat-seltext_l     = ‘제품명’.
  APPEND i_fieldcat TO  i_fieldcat_alv.
 
  pos = pos + 1.
  i_fieldcat-col_pos       =  pos.
  i_fieldcat-fieldname     = ‘OQUANTI’.
  i_fieldcat-seltext_l     = ‘주문수량’.
  APPEND i_fieldcat TO  i_fieldcat_alv.
 
  pos = pos + 1.
  i_fieldcat-col_pos       =  pos.
  i_fieldcat-fieldname     = ‘OVALUE’.
  i_fieldcat-seltext_l     = ‘주문실적’.
  APPEND i_fieldcat TO  i_fieldcat_alv.
 
  pos = pos + 1.
  i_fieldcat-col_pos       =  pos.
  i_fieldcat-fieldname     = ‘OCURRENCY’.
  i_fieldcat-seltext_l     = ‘단위’.
  APPEND i_fieldcat TO  i_fieldcat_alv.
 
  pos = pos + 1.
  i_fieldcat-col_pos       =  pos.
  i_fieldcat-fieldname     = ‘DDOC’.
  i_fieldcat-seltext_l     = ‘납품문서번호’.
  APPEND i_fieldcat TO  i_fieldcat_alv.
 
  pos = pos + 1.
  i_fieldcat-col_pos       =  pos.
  i_fieldcat-fieldname     = ‘DITEM’.
  i_fieldcat-seltext_l     = ‘아이템’.
  APPEND i_fieldcat TO  i_fieldcat_alv.
 
  pos = pos + 1.
  i_fieldcat-col_pos       =  pos.
  i_fieldcat-fieldname     = ‘IDOC’.
  i_fieldcat-seltext_l     = ‘대금청구번호’.
  APPEND i_fieldcat TO  i_fieldcat_alv.
 
  pos = pos + 1.
  i_fieldcat-col_pos       =  pos.
  i_fieldcat-fieldname     = ‘IITEM’.
  i_fieldcat-seltext_l     = ‘아이템번호’.
  APPEND i_fieldcat TO  i_fieldcat_alv.
 
  CLEAR i_fieldcat.
ENDFORM.                    "fields
 
*———————————————————————-*
*form display_data
**
*———————————————————————-*
FORM display_data.
  w_repid = sy-repid.
  CALL FUNCTION ‘REUSE_ALV_LIST_DISPLAY’
    EXPORTING
      i_callback_program = w_repid
      i_callback_user_command = ‘USER_COMMAND’
   is_layout = i_layout
   it_events = alv_event[]
*      i_save             = ‘ ‘
      it_fieldcat        = i_fieldcat_alv[]
    TABLES
      t_outtab           = itab.
ENDFORM.                    "display_data
*———————————————————————-*
*form layout_build
**
*———————————————————————-*
Form layout_build.
*   I_layout-detail_popup      = ‘X’.  " Display row in popup
   I_layout-get_selinfos      =X’.  " Read selection screen in
   i_layout-colwidth_optimize =X’.
*   layout-zebra             = ‘X’.  "striped pattern
*   I_layout-f2code            = ‘&ETA’.
 
endform.                    " BUILD_LAYOUT
 
*———————————————————————-*
*      <–P_ALV_EVENT  text
*———————————————————————-*
FORM append_alv_event CHANGING p_alv_event TYPE slis_t_event.
  DATA ls_events TYPE slis_alv_event.
  ls_events-name = ‘USER_COMMAND’.
  ls_events-form = ‘USER_COMMAND’.
  APPEND ls_events TO p_alv_event.
*  ls_events-name = ‘TOP_OF_PAGE’.
*  ls_events-form = ‘TOP_OF_PAGE’.
*  APPEND ls_events TO p_alv_event.
ENDFORM.                    " append_alv_event
*&———————————————————————*
*&      Form  LINE_SELECTION
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM user_command USING r_ucomm LIKE sy-ucomm
                        rs_selfield TYPE slis_selfield.
  CHECK r_ucomm EQ&IC1′ AND NOT rs_selfield-value IS INITIAL.
  CASE rs_selfield-fieldname.
    WHEN ‘ITAB-SDOC’.
      SET PARAMETER ID ‘AUN’ FIELD rs_selfield-valuE.
      CALL TRANSACTION ‘VA03′ AND SKIP FIRST SCREEN.
    WHEN ‘ITAB-DDOC’.
      SET PARAMETER ID ‘VL’ FIELD rs_selfield-value.
      CALL TRANSACTION ‘VL03N’ AND SKIP FIRST SCREEN.
 
    WHEN ‘ITAB-IDOC’.
      SET PARAMETER ID ‘VF’ FIELD rs_selfield-value.
      CALL TRANSACTION ‘VF03′ AND SKIP FIRST SCREEN.
  ENDCASE.

TAGS: , , , ,
Apr 16 2009

ABAP Tips Block Input Area Tip

How to block input area? You can check below method.

input

1
2
3
4
5
6
7
8
9
PARAMETERS: p_werks LIKE mseg-werks OBLIGATORY DEFAULT ‘PHAS’ MODIF ID bl2.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-name = ‘P_WERKS’ .
screen-input =0′.
screen-output =1′.
MODIFY SCREEN.
ENDIF.
ENDLOOP.

TAGS: , ,
Apr 16 2009

ABAP ALV Double Click CO03

My client asks me to add a function that when he double click order column, he wants to see CO03.
Below is the ABAP code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
*&———————————————————————*
*&      Form  LINE_SELECTION
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CHECK r_ucomm EQ&IC1′ AND NOT rs_selfield-value IS INITIAL.
CASE rs_selfield-fieldname.
WHEN ‘AUFNR’.
SET PARAMETER ID ‘ANR’ FIELD rs_selfield-value.
CALL TRANSACTION ‘CO03′ AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM.                    ” LINE_SELECTION

Apr 16 2009

ABAP Create Excel Download button at Selection Screen

If you want to create Excel download button at selection screen, you can check below method.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
TABLES: sscrfields.
 
INITIALIZATION.
 
PERFORM init_data.
 
PERFORM file_download.
 
*&———————————————————————*
*&      Form  INIT_DATA
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM INIT_DATA .
 
sscrfields-functxt_01 = text-f01.
 
ENDFORM.                    ” INIT_DATA
*&———————————————————————*
*&      Form  FILE_DOWNLOAD
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM FILE_DOWNLOAD .
 
DATA : t_dfname   TYPE rlgrap-filename VALUEC:\’,
t_filename TYPE string.
 
* download file name
CALL FUNCTION ‘F4_FILENAME’
EXPORTING
program_name  = sy-repid
dynpro_number = sy-dynnr
IMPORTING
file_name     = t_dfname.
 
* file name
t_filename = t_dfname.
 
IF t_filename IS INITIAL OR
t_filename =C:\’.
MESSAGE ‘파일 경로를 입력해 주세요.’ TYPEI’.
STOP.
ENDIF.
 
* download template
CALL FUNCTION ‘GUI_DOWNLOAD’
EXPORTING
filename = t_filename
filetype = ‘DAT’
TABLES
data_tab = <gt_table>.
 
CALL FUNCTION ‘MS_EXCEL_OLE_STANDARD_DAT’
EXPORTING
file_name                 = t_dfname
TABLES
data_tab                  = <gt_table>
fieldnames                = it_head
EXCEPTIONS
file_not_exist            = 1
filename_expected         = 2
communication_error       = 3
ole_object_method_error   = 4
ole_object_property_error = 5
invalid_pivot_fields      = 6
download_problem          = 7
OTHERS                    = 8.
 
IF sy-subrc <> 0.
MESSAGE ‘Excel Open Error’ TYPEI’.                   “#EC NOTEXT
STOP.
ENDIF.
 
ENDFORM.                    ” FILE_DOWNLOAD

Apr 16 2009

Calculate Days Function-FIMA_DAYS_AND_MONTHS_AND_YEARS

Use below ABAP function, you can calculate days.

1
2
3
4
5
6
7
8
9
10
11
12
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
  EXPORTING
    I_DATE_FROM = '19991008'
    I_DATE_TO   = '20000116' 
  IMPORTING
    E_DAYS      = T_DAYS 
    E_MONTHS    = T_MONTHS
    E_YEARS     = T_YEARS.
 
Result :  T_DAYS   = 466 
          T_MONTHS = 16  
          T_YEARS  = 2

TAGS: , ,
Mar 25 2009

ABAP Function-Z_GET_EOH_VALUE

Using ABAP fuction “Z_GET_EOH_VALUE”, we can get Begining Stock, Begining AMT, Ending Stock, Ending AMT.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
*Ending Stock &amp; AMT
 
DATA: WA_EOH LIKE MBEWH.
*If ther is no To(From~To)
IF P_MONAT-HIGH = '00'.
P_MONAT-HIGH = P_MONAT-LOW.
ENDIF.
LOOP AT IT_MAIN.
CALL FUNCTION 'Z_GET_EOH_VALUE'
EXPORTING
matnr         = it_main-matnr
bwkey         = it_main-werks
lfgja         = p_gjahr
lfmon         = p_monat-high
IMPORTING
eoh           = wa_eoh.
IF sy-subrc = 0.
it_main-LLBKUM = wa_eoh-lbkum.
it_main-LSALK3 = wa_eoh-SALK3.
ENDIF.
*Beginning Stock and AMT
CLEAR WA_EOH.
DATA: TEMP_MONAT LIKE IT_MAIN-MONAT.
DATA: TEMP_GJAHR LIKE P_GJAHR.
IF P_MONAT-LOW = '01'.
TEMP_MONAT = '12'.
TEMP_GJAHR = P_GJAHR - 1.
ELSE.
TEMP_MONAT = P_MONAT-LOW - 1.
TEMP_GJAHR = P_GJAHR.
ENDIF.
CALL FUNCTION 'Z_GET_EOH_VALUE'
EXPORTING
matnr         = it_main-matnr
bwkey         = it_main-werks
lfgja         = TEMP_GJAHR
lfmon         = TEMP_MONAT
IMPORTING
eoh           = wa_eoh.
 
IF sy-subrc = 0.
it_main-LBKUM = wa_eoh-lbkum.
it_main-SALK3 = wa_eoh-SALK3.
ENDIF.
 
MODIFY IT_MAIN.
ENDLOOP.