Showing posts with label ABAP. Show all posts
Showing posts with label ABAP. Show all posts
From Release 4.0 the previously 1-character language key has 2-characters as in ISO Code 639. For example, English is now 'EN' insead of 'E', Hebrew is 'HE' instead of 'B' and Korean is 'KO' instead of '3'. Script :

data : lv_output(1).

call function 'CONVERSION_EXIT_ISOLA_INPUT'
exporting
    input = 'ID'     " ID -> Indonesia
importing
    output = lv_output.


write lv_output.
Posted by Shanto Labels: ,
Sunday, March 4, 2012 at 7:07 PM | 0 comments
Sometimes we need to change the printer spool into default, we can use tcode su01 or su10.

Please see capture below.

Posted by Shanto Labels:
Tuesday, November 22, 2011 at 1:20 AM | 0 comments
In SAP ABAP you can read file with open dataset,
The command used to read a file on the application server is as follows.

OPEN DATASET ... FOR INPUT

Please see example code below.

REPORT YSANTO_12 .

data: lv_fname(100),
       &nbsp   lv_msg like sy-msgv1.

data: begin of gi_data occurs 0,
      &nbsp  &nbsp  &nbsp   txt(255),
       &nbsp   end of gi_data.


lv_fname = '/home/data/data.txt'.

open dataset lv_fname for input message lv_msg in text mode encoding default.

if sy-subrc = 0.
    &nbsp do.
    &nbsp   read dataset lv_fname into gi_data-txt.
    &nbsp   if sy-subrc <> 0.
    &nbsp       &nbsp   exit.
    &nbsp   endif.
    &nbsp   append gi_data.
    &nbsp   clear gi_data.
    &nbsp enddo.
else.
    &nbsp   write 'File does not exist!'.
endif.

close dataset lv_fname.
Posted by Shanto Labels:
Sunday, November 20, 2011 at 11:08 PM | 0 comments
Here is an example of how to FTP a file from the Application server to a remote server using standard SAP functions.


REPORT YSANTO_12 .

data: begin of gi_data occurs 0,
                line(132) type c,
           end of gi_data.

data: lv_password(20) type c,
           lv_key type i value 26101957,
           lv_pwd_len type I,
           lv_handle type I.

START-OF-SELECTION.

lv_password = 'password'.

describe field lv_password length lv_pwd_len in character mode.


call 'AB_RFC_X_SCRAMBLE_STRING'
           id 'SOURCE' field lv_password id 'KEY' field lv_key
           id 'SCR' field 'X' id 'DESTINATION' field lv_password
           id 'DSTLEN' field lv_pwd_len.

call function 'FTP_CONNECT'
         exporting
           user = 'userid'
           password = lv_password
           host = 'host'
           rfc_destination = 'SAPFTP'
         importing
           handle = lv_handle
         exceptions
           not_connected = 1
           others = 2.

check sy-subrc = 0.

call function 'FTP_COMMAND'
         exporting
           handle = lv_handle
           command = 'dir'    " for get file -> exe commnad 'asci'
         tables                          " then exe command 'get sourcefile targetfile'.
           data = gi_data
         exceptions
           tcpip_error = 1
           command_error = 2
           data_error = 3
           others = 4.


call function 'FTP_DISCONNECT'
         exporting
           handle = lv_handle
         exceptions
           others = 1.

Posted by Shanto Labels: ,
Friday, November 4, 2011 at 12:51 AM | 0 comments
What is Data Archiving?
Data Archiving is a decongestion process used to delete large volume of data that is no longer needed from a database and storing same outside the database in a format that allows for data retrieval and analysis when need be. The emphasis here are on “deleting” and “storing”. It is common knowledge that if a database is left to grow unmaintained, there is a possibility of having performance bottlenecks and high database maintenance cost. Hence, one of the ways to maintain the database is to delete records that can be termed obsolete. The word “obsolete” is relative. For the archiving process to be complete, data has to be stored using a defined method.

How is data archived?
The data archiving run follows a sequence of steps. A brief overview is provided below.
1. Creation of the archive file: During an archive run, the write program first creates archive files which initiates the reading process (from the database) and the consequent writing process (to the archive file)

2. Storage of the archive file: After successful run of step 1, the created archive files are stored. A number of methods can be leveraged to store an archive file. Archived files can be stored hierarchically, optically or manually. It is important to state that SAP does not recommend the manual storage of archive file. This is as a result of some standardization issues

3. Deletion of data: This step terminates the archive run. Before data is deleted from the database, the program first read the content of the archive file. It is after this task, that the program deletes the corresponding entry from the database.

Benefits of Data Archiving
1. Reduced Backup and Restore time
2. Reduced access time for tables
3. Reduced database administration cost
4. Reduced downtime for system upgrade
5. Reusability of data


Ref : http://it.toolbox.com/blogs/sap-library/introduction-to-sap-data-archiving-27976
Posted by Shanto Labels:
Monday, October 11, 2010 at 12:59 AM | 0 comments

Tahapan untuk memanggil SmartForms :
- Sebelumnya buat form seperti di samping, untuk codenya bisa dilihat di bawah.







REPORT YTEST.

data : gv_func_module_name type rs38l_fnam,
   gs_control_parameters type ssfctrlop,
   gs_output_options type ssfcompop.

constants: cn_form(30) value 'YTEST'.


parameters: pa_prm1 type c length 30.
parameters: pa_prm2 type c length 30.


call function 'SSF_FUNCTION_MODULE_NAME'
   exporting
      formname = cn_form
   importing
      fm_name = gv_func_module_name
   exceptions
      no_form = 1
      no_function_module = 2
      others = 3.
if sy-subrc <> 0. exit. endif.

gs_control_parameters-preview = 'X'.
gs_output_options-tdnewid = 'X'.
gs_output_options-tddelete = 'X'.
gs_output_options-tdimmed = 'X'.

call function gv_func_module_name
   exporting
      control_parameters = gs_control_parameters
      output_options = gs_output_options
      user_settings = ' '
      pa_param1 = pa_prm1
      pa_param2 = pa_prm2
*   tables
*      gi_ytest = gi_ytest
   exceptions
      formatting_error = 1
      internal_error = 2
      send_error = 3
      user_canceled = 4
      others = 5.

- Tetapi sebelum di execute, kita harus buat smartforms dahulu.
dimana parameter pa_prm1 dan parame2 akan kita lempar ke smartforms.



- Klik 2x di Form Interface kemudian tambahkan pa_param1 dan pa_param2 di tab import.



- Klik 2x di %TEXT1 tambahkan PA_PRM1 : &pa_param1&


- Klik 2x di %TEXT2 tambahkan PA_PRM2 : &pa_param2& ( sama seperti di atas )
- kemudan jalankan dan akan terlihat seperti dibawah.

Posted by Shanto Labels:
Bagaimana merubah page orientation (Portrait/Landscape) di SmartForm.

1. Pertama buka smartform ( tcode smartforms ).
2. Klik 2x TEST, Klik "Output Options" tab, Disana akan terlihat print attributes kemudian pilih Page Format.

Capture Screen :

Posted by Shanto Labels:
Wednesday, October 6, 2010 at 5:58 AM | 0 comments
Fungsi DateDiff adalah mengembalikan jumlah interval antara dua tanggal itu di VB, sedangkan di ABAP kita bisa mengunakan fungsi DAYS_BETWEEN_TWO_DATES.

Contoh :

CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
   i_datum_bis = '20080401'
   i_datum_von = '20080327'
   i_stgmeth = 2
IMPORTING
   e_tage = output_interval.
Posted by Shanto Labels:
Friday, September 24, 2010 at 3:25 AM | 0 comments
Tabel Penting di Modul Production Planning (PP)

Work center
CRHH - Work center hierarchy
CRHS - Hierarchy structure
CRHD - Work center header
CRTX - Text for the Work Center or Production Resource/Tool
CRCO - Assignment of Work Center to Cost Center
KAKO - Capacity Header Segment
CRCA - Work Center Capacity Allocation
TC24 - Person responsible for the work center


Routings/operations
MAPL - Allocation of task lists to materials
PLAS - Task list - selection of operations/activities
PLFH - Task list - production resources/tools
PLFL - Task list - sequences
PLKO - Task list - header
PLKZ - Task list: main header
PLPH - Phases / suboperations
PLPO - Task list operation / activity
PLPR - Log collector for tasklists
PLMZ - Allocation of BOM - items to operations

Bill of material
STKO - BOM - header
STPO - BOM - item
STAS - BOMs - Item Selection
STPN - BOMs - follow-up control
STPU - BOM - sub-item
STZU - Permanent BOM data
PLMZ - Allocation of BOM - items to operations
MAST - Material to BOM link
KDST - Sales order to BOM link

Production orders
AUFK - Production order headers
AFIH - Maintenance order header
AUFM - Goods movement for prod. order
AFKO - Order header data PP orders
AFPO - Order item
RESB - Order componenten
AFVC - Order operations
AFVV - Quantities/dates/values in the operation
AFVU - User fields of the operation
AFFL - Work order sequence
AFFH - PRT assignment data for the work order(routing)
JSTO - Status profile
JEST - Object status
AFRU - Order completion confirmations

PRT’s production orders
AFFH - PRT assignment data for the work order
CRVD_A - Link of PRT to Document
DRAW - Document Info Record
TDWA - Document Types
TDWD - Data Carrier/Network Nodes
TDWE - Data Carrier Type

Planned orders
PLAF - Planned orders

KANBAN
PKPS - Kanban identification, control cycle
PKHD - Kanban control cycle (header data)
PKER - Error log for Kanban containers

Reservations
RESB - Material reservations
RKPF - Header

Capacity planning
KBKO - Header record for capacity requirements
KBED - Capacity requirements records
KBEZ - Add. data for table KBED (for indiv. capacities/splits)

Planned independent requirements
PBIM - Independent requirements for material
PBED - Independent requirement data
PBHI - Independent requirement history
PBIV - Independent requirement index
PBIC - Independent requirement index for customer req.

Ref : http://www.sap-basis-abap.com/pp/the-table-names-of-sap-pp-module.htm
Posted by Shanto Labels:
Di SAP tanda negative di default diletakan setelah angka, dalam suatu kasus kadang-kadang kita ingin meletakan sebelum angka. Ada sebuah function yang bisa di gunakan untuk memindahkan tanda negative tersebut agar di depan.



REPORT YSANTO_01.

data: lv_kbetr type i, lv_kbetr_c(13).

lv_kbetr = -1000.

write lv_kbetr to lv_kbetr_c.

CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
VALUE = lv_kbetr_c.

write / lv_kbetr.
write / lv_kbetr_c.

Posted by Shanto Labels:
Kadang-kadang kita sering mendebug mencari user exit pada tcode tertentu, dan ini sangat membutuhkan waktu yang lama. Ternyata user exit bisa di list dengan program simple di bawah.



REPORT ysanto_11 .

TABLES : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir.
TABLES : tstct.

DATA : jtab LIKE tadir OCCURS 0 WITH HEADER LINE.
DATA : field1(30).
DATA : v_devclass LIKE tadir-devclass.

PARAMETERS : p_tcode LIKE tstc-tcode OBLIGATORY.

SELECT SINGLE * FROM tstc WHERE tcode EQ p_tcode.

IF sy-subrc EQ 0.

SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR' AND object = 'PROG' AND obj_name = tstc-pgmna.

MOVE : tadir-devclass TO v_devclass.
IF sy-subrc NE 0.

SELECT SINGLE * FROM trdir WHERE name = tstc-pgmna.
IF trdir-subc EQ 'F'.

SELECT SINGLE * FROM tfdir WHERE pname = tstc-pgmna.
SELECT SINGLE * FROM enlfdir WHERE funcname = tfdir-funcname.

SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR' AND object = 'FUGR' AND obj_name EQ enlfdir-area.

MOVE : tadir-devclass TO v_devclass.
ENDIF.
ENDIF.

SELECT * FROM tadir INTO TABLE jtab WHERE pgmid = 'R3TR' AND object = 'SMOD' AND devclass = v_devclass.

SELECT SINGLE * FROM tstct WHERE sprsl EQ sy-langu AND tcode EQ p_tcode.

FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.

WRITE: /(19) 'Transaction Code – ',
20(20) p_tcode,
45(50) tstct-ttext.

SKIP.

IF NOT jtab[] IS INITIAL.

WRITE:/(95) sy-uline.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/1 sy-vline,
2 'Exit Name',
21 sy-vline ,
22 'Description',
95 sy-vline.
WRITE:/(95) sy-uline.

LOOP AT jtab.
SELECT SINGLE * FROM modsapt WHERE sprsl = sy-langu AND name = jtab-obj_name.

FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
WRITE:/1 sy-vline,
2 jtab-obj_name HOTSPOT ON,
21 sy-vline ,
22 modsapt-modtext,
95 sy-vline.
ENDLOOP.

WRITE:/(95) sy-uline.
DESCRIBE TABLE jtab.

SKIP.

FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ 'No of Exits:' , sy-tfill.

ELSE.

FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.

WRITE:/(95) 'No User Exit exists'.

ENDIF.

ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(95) 'Transaction Code Does Not Exist'.
ENDIF.

AT LINE-SELECTION.
GET CURSOR FIELD field1.
CHECK field1(4) EQ 'JTAB'.
SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.


























Ref : http://www.sap-img.com/ab038.htm
Posted by Shanto Labels:
Thursday, April 8, 2010 at 2:40 AM | 0 comments
Pada dasarnya pada saat membuat program di abap terdiri dari beberapa event:
1. Initialization
Di event Initialization kita bisa memberikan nilai default terhadap suatu variabel. Karena pada saat ini line code akan di execute sebelum screen di tampilkan.


2. At selection screen
Event ini akan di jalankan jika terjadi perubahan di screen
3. Start of selection
Event ini akan dijalankan jika melakukan execute terhadap program tersebut.
4. Block Program yang di buat
Di sinilah suatu block program yang akan dibuat baik select, insert, update, insert atau proses.
5. End of selection
Disini adalah akhir dari suatu execute.
6. At line selection
Ini akan dijalan kan jika terjadi event terhadap screen result yang telah di tampilkan.

Sample Program :color:

REPORT YSANTO_01.
tables: spfli.

data: wa_spfli type spfli,
wa_sflig type spfli.

parameters par_cid like spfli-carrid.

initialization.
par_cid = 'MH'.

at selection-screen.
if par_cid = ''.
message e000(38) with 'Carr ID harus di isi'.
endif.

start-of-selection.
select single * from spfli into wa_spfli where carrid = par_cid.
if sy-subrc = 0.
write wa_spfli-carrid.
endif.

end-of-selection.

at line-selection.
select single * from spfli into wa_sflig where carrid = wa_spfli-carrid.
if sy-subrc = 0.
write: / 'Asal Penerbangan : ', wa_sflig-cityfrom.
write: / 'Tujuan Penerbangan : ', wa_sflig-cityto.
endif.

Output :







Result after execute :





After double click :





Ternyata abap itu mudah, betul betul ....
Posted by Shanto Labels:
Wednesday, February 17, 2010 at 12:23 AM | 0 comments
Gw sempat di tanya apakah table sap datanya bisa langsung di edit, gw bilang ngk tau sepengalaman gw sih belum pernah, maklumlah newbie. setelah beberapa hari gw iseng googgling nah kan ketemu


Caranya langsung aja ke SE16N kemudian masukan tablenya sebelum di execute ketikan &sap_edit langsung di enter akan muncul message : SAP editing function is activated kemudian execute dan..... table langsung bisa edit.

Tapi PERHATIAN ini jangan dilakukan kalau memang kita tidak tau tabel-table yang berhubungan.

http://www.kowboyz.nl/blog/edit-sap-tables/
Posted by Shanto Labels:
Tuesday, February 16, 2010 at 7:46 PM | 0 comments
Tugas berikutnya fixing report jamsostek ada nik yang tampil double dan ada yang tidak tampil. berati harus di debug dong. pertama setelah form muncul kemudian pilih seleksinya sebelum di execute ketik /h enter ( akan muncul debug switch on ). berarti siap di execute.
abrakedabra. munculah script abap nya, setelah di debug secara internal table nilainya sudah benar dan kemudian gw cek smartformsnya nah ini dia ketemu ternyata yang seharusnya membaca internal table sequance 1, 2, 3 dst tetapi pada saat halaman berikutnya akan balik ke sequance 1 kemudian sequance sebelumnaya + 1 sehingga nik yang sebelumnya tidak muncul dan nik pada saat balik ke sequance 1 menuncul kembali.

Setelah di coba beberapa cara akhirnya di ketemukan caranya : yaitu menambahkan Table Line di Main Area yang berfungsi memaksa balik ke sequance yang sebenarnya.

Tugas Done.
Posted by Shanto Labels:
Setelah mendapat traning secukupnya tiba saatnya untuk mejalankan tugas :
Request yang diminta, tolong di tampilkan artike detail bom dengan total qty bom, qty dan value per sloc.

Tabel yang berhubungan :
1. MAST -> Article to BOM Link
2. STPO -> BOM item
3. MAKT - > Article Descriptions
4. MBEW -> Article Valuation
5. MARD -> Storage Location Data for Article
6. MARA -> General Article Data
7. STAS -> BOMs - Item Selection

Link Table :














Result Report :


Tugas Done.
Posted by Shanto Labels: