Google Search - Blog...........

ABAP - Checkbox In ALV Program

REPORT ZTEST .

type-pools: slis.

*Table declaration
tables: vbak,vbap.

*internal table
data: begin of i_sales occurs 0,
vbeln like vbak-vbeln,
erdat like vbak-erdat,
audat like vbak-audat,
kunnr like vbak-kunnr,
vkorg like vbak-vkorg,
matnr like vbap-matnr,
netpr like vbap-netpr,
check type c, "checkbox
end of i_sales.

data: begin of i_final occurs 0,
vbeln like vbak-vbeln,
erdat like vbak-erdat,
audat like vbak-audat,
kunnr like vbak-kunnr,
vkorg like vbak-vkorg,
matnr like vbap-matnr,
netpr like vbap-netpr,
end of i_final.

data: v_fieldcat type slis_fieldcat_alv,
gt_fieldcat type slis_t_fieldcat_alv,
gt_layout type slis_layout_alv,
gt_sort type slis_sortinfo_alv,
fieldcat like line of gt_fieldcat.

*Selection screen
parameters: p_vkorg like vbak-vkorg.
select-options: s_vbeln for vbak-vbeln.

*start of selection.
start-of-selection.
perform get_data.
perform fill_fieldcatalog.
perform write_data.
*-----------------------------------------------------------------
* get data
*-----------------------------------------------------------------
FORM get_data .
select a~vbeln
a~erdat
a~audat
a~kunnr
a~vkorg
b~matnr
b~netpr
into corresponding fields of table i_sales
from vbak as a inner join vbap as b on a~vbeln = b~vbeln
where a~vkorg = p_vkorg
and a~vbeln in s_vbeln.

ENDFORM. " get_data
*-----------------------------------------------------------------
* write_data
*-----------------------------------------------------------------
FORM write_data .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = 'GUI_SET'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = gt_layout
IT_FIELDCAT = gt_fieldcat
TABLES
T_OUTTAB = i_sales .

ENDFORM. " write_data
*-----------------------------------------------------------------
* fill catalog
*-----------------------------------------------------------------
FORM fill_fieldcatalog .

sort i_sales by vbeln.
clear v_fieldcat.
*for check box

v_fieldcat-col_pos = 1.
v_fieldcat-fieldname = 'CHECK'.
v_fieldcat-seltext_m = 'chek'.
v_fieldcat-checkbox = 'X'.
v_fieldcat-input = 'X'.
v_fieldcat-edit = 'X'.
append v_fieldcat to gt_fieldcat.

clear v_fieldcat.
v_fieldcat-col_pos = 2.
v_fieldcat-fieldname = 'VBELN'.
v_fieldcat-seltext_m = 'Sales Document'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.

v_fieldcat-col_pos = 3.
v_fieldcat-fieldname = 'ERDAT'.
v_fieldcat-seltext_m = 'Creation Date'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.

v_fieldcat-col_pos = 4.
v_fieldcat-fieldname = 'AUDAT'.
v_fieldcat-seltext_m = 'Document Date'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.

v_fieldcat-col_pos = 5.
v_fieldcat-fieldname = 'KUNNR'.
v_fieldcat-seltext_m = 'Customer'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.

v_fieldcat-col_pos = 6.
v_fieldcat-fieldname = 'VKORG'.
v_fieldcat-seltext_m = 'Sales Organization'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.

v_fieldcat-col_pos = 7.
v_fieldcat-fieldname = 'MATNR'.
v_fieldcat-seltext_m = 'Material'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.

v_fieldcat-col_pos = 8.
v_fieldcat-fieldname = 'NETPR'.
v_fieldcat-seltext_m = 'Net Value'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.

endform.

*&---------------------------------------------------------------------*
*& Form GUI_SET
*&---------------------------------------------------------------------*
FORM GUI_SET USING RT_EXTAB TYPE SLIS_T_EXTAB .


SET PF-STATUS 'GETDATA' .

ENDFORM. "GUI_SET
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*

FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
R_SELFIELD TYPE SLIS_SELFIELD.


CASE R_UCOMM.
WHEN 'DATA'.
CLEAR I_FINAL.
CLEAR I_SALES.
REFRESH I_FINAL.

LOOP AT i_sales .
if i_sales-check = 'X'.
i_final-vbeln = i_sales-vbeln.
i_final-erdat = i_sales-erdat.
i_final-audat = i_sales-audat.
i_final-kunnr = i_sales-kunnr.
i_final-vkorg = i_sales-vkorg.
i_final-matnr = i_sales-matnr.
i_final-netpr = i_sales-netpr.

IF NOT I_FINAL-VBELN IS INITIAL.
append i_final .
ENDIF.

endif.
ENDLOOP.
PERFORM final_display.

endcase.

ENDFORM. "USER_COMMAND
*&---------------------------------------------------------------------*
*& Form final_display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------*

form final_display .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = gt_LAYOUT
IT_FIELDCAT = gt_fieldcat
TABLES
t_outtab = i_final .
endform. " final_display


ALSO READ:



ABAP - Simple ALV Total Display Program.

REPORT zdemo_alvgrid .

type-pools: slis.
*Data Declaration
data: BEGIN OF itab occurs 0,
F1 TYPE I,
F2 TYPE I,
F3 TYPE I,
END OF itab.

data: it_fieldcatalog type slis_t_fieldcat_alv ,
wa_fieldcatalog type slis_fieldcat_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.

itab-f1 = '1'.
itab-f2 = '10'.
itab-f3 = '1234'.
append itab.

itab-f1 = '2'.
itab-f2 = '400'.
itab-f3 = '4321'.
append itab.

itab-f1 = '3'.
itab-f2 = '5120'.
itab-f3 = '0766'.
append itab.

itab-f1 = '4'.
itab-f2 = '620'.
itab-f3 = '3245'.
append itab.

itab-f1 = '5'.
itab-f2 = '9430'.
itab-f3 = '564'.
append itab.

itab-f1 = '6'.
itab-f2 = '1098'.
itab-f3 = '14'.
append itab.

itab-f1 = '7'.
itab-f2 = '140'.
itab-f3 = '4325'.
append itab.


wa_fieldcatalog-fieldname = 'F1'.
wa_fieldcatalog-reptext_ddic = 'field1'.
append wa_fieldcatalog to it_fieldcatalog .
clear wa_fieldcatalog .

wa_fieldcatalog-fieldname = 'F2'.
wa_fieldcatalog-reptext_ddic = 'field2'.
wa_fieldcatalog-do_sum = 'X'.
append wa_fieldcatalog to it_fieldcatalog .
clear wa_fieldcatalog .

wa_fieldcatalog-fieldname = 'F3'.
wa_fieldcatalog-reptext_ddic = 'field3'.
wa_fieldcatalog-do_sum = 'X'.
append wa_fieldcatalog to it_fieldcatalog .
clear wa_fieldcatalog .

* gd_layout-
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'.

gd_repid = sy-repid.

call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = gd_repid
is_layout = gd_layout
it_fieldcat = it_fieldcatalog[]
tables
t_outtab = itab .


ALSO READ:

- Simple ALV Grid/List With Save Layout.

- Checkbox In ALV Program.

- ALV Header With Logo.

- Including Line After Subtotal In ALV Display.

..... Back To Index On ALV List/ Grid Display.

..... Back To MAIN INDEX.


ABAP - Simple List Interactive Report Program.

REPORT zintractive .

TYPES : BEGIN OF str_mard,
matnr TYPE mard-matnr,
lgort TYPE mard-lgort,
werks TYPE mard-werks,
END OF str_mard.
DATA : wa_mard TYPE str_mard,
it_mard TYPE TABLE OF str_mard.
TYPES : BEGIN OF str_makt,
matnr TYPE makt-matnr,
maktg TYPE makt-maktg,
END OF str_makt.
DATA : wa_makt TYPE str_makt,
it_makt TYPE TABLE OF str_makt.

TYPES : BEGIN OF str_mara,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
laeda TYPE mara-laeda,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
meins TYPE mara-meins,
END OF str_mara.

DATA : wa_mara TYPE str_mara,
it_mara TYPE TABLE OF str_mara.

TYPES : BEGIN OF str_final,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
laeda TYPE mara-laeda,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
meins TYPE mara-meins,
lgort TYPE mard-lgort,
werks TYPE mard-werks,
END OF str_final.

DATA: wa_final TYPE str_final,
it_final TYPE TABLE OF str_final.

PARAMETERS : plant TYPE mard-werks,
stor LIKE mard-lgort.


SELECT matnr
lgort
werks
FROM mard
INTO TABLE it_mard
WHERE lgort = stor AND werks = plant.

.SELECT matnr
maktg
FROM makt
INTO TABLE it_makt
FOR ALL ENTRIES IN it_mard
WHERE matnr = it_mard-matnr
AND spras = 'E'.

SELECT matnr
ersda
ernam
laeda
mtart
matkl
meins
FROM mara
INTO TABLE it_mara
FOR ALL ENTRIES IN it_makt
WHERE matnr = it_makt-matnr.

LOOP AT it_makt INTO wa_makt.
WRITE : /1 wa_makt-matnr COLOR 1,
40 wa_makt-maktg COLOR 2.
HIDE wa_makt-matnr.
ENDLOOP.

CLEAR wa_mard-matnr.

AT LINE-SELECTION.
REFRESH it_final.
CLEAR wa_final.
ULINE.
IF sy-lsind = 1.
WRITE : /1 'MATERIAL NO' COLOR 2,
20 'CREATION DATE' COLOR 3,
32 'PERSON CREATED',
50 'DATE OF LIST' ,
65 'MATERIALTYPE',
80 'MATGROUP' ,
90 'UNITOFMEASURE',
110 'STORLOCATION' COLOR 4,
130 'PLANT' COLOR 5.
ULINE.
ENDIF.

LOOP AT it_mara INTO wa_mara WHERE matnr = wa_makt-matnr.
wa_final-matnr = wa_mara-matnr.
wa_final-ersda = wa_mara-ersda.
wa_final-ernam = wa_mara-ernam.
wa_final-laeda = wa_mara-laeda.
wa_final-mtart = wa_mara-mtart.
wa_final-matkl = wa_mara-matkl.
wa_final-meins = wa_mara-meins.

READ TABLE it_mard INTO wa_mard WITH KEY matnr = wa_makt-matnr.
wa_final-lgort = wa_mard-lgort.
wa_final-werks = wa_mard-werks.
APPEND wa_final TO it_final.
ENDLOOP.

LOOP AT it_final INTO wa_final.
WRITE :
/1 wa_final-matnr
COLOR 2,
20 wa_final-ersda ,
37 wa_final-ernam,
50 wa_final-laeda ,
70 wa_final-mtart ,
85 wa_final-matkl ,
95 wa_final-meins,
115 wa_final-lgort ,
130 wa_final-werks .
ENDLOOP.

TOP-OF-PAGE.
WRITE : /1 'MATERIAL NO' COLOR 1,
40 'DISCRIPTION' COLOR 2.
ULINE .

ABAP - Delete, Append & Modify Internal table With Header Line.

report .

data: begin of itab occurs 0,
name(10) type c,
age type i,
end of itab .
selection-screen begin of line .
parameters:p_wa(100) type c .
selection-screen end of line .
selection-screen skip 2.
selection-screen begin of line .
SELECTION-SCREEN:
PUSHBUTTON 2(10) but1 USER-COMMAND cli1,
PUSHBUTTON 15(20) but2 USER-COMMAND cli2 ,
PUSHBUTTON 40(20) but3 USER-COMMAND cli3 visible length 5 .

selection-screen end of line .

at selection-screen .

case sy-ucomm .

when 'CLI1'.
itab-name = p_wa+0(10) .
itab-age = p_wa+11(2).
append itab.

when 'CLI2'.
delete itab where name = p_wa+0(10) .

when 'CLI3'.
read table itab with key name = p_wa+0(10).
if sy-subrc = 0.

modify itab transporting name age.
else .
exit.
endif .

endcase .


start-of-selection .

loop at itab.
write:/ itab-name .
endloop.

ABAP - Finding Userexits For Any Transaction - Report Program.

REPORT z_find_userexit NO STANDARD PAGE HEADING.

TABLES : tstc, "SAP Transaction Codes
tadir, "Directory of Repository Objects
modsapt, "SAP Enhancements - Short Texts
modact, "Modifications
trdir, "System table TRDIR
tfdir, "Function Module
enlfdir, "Additional Attributes for Function Modules
tstct. "Transaction Code Texts

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

*&---------------------------------------------------------------------*
*& Selection Screen Parameters
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK a01 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS : p_tcode LIKE tstc-tcode OBLIGATORY.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK a01.

*&---------------------------------------------------------------------*
*& Start of main program
*&---------------------------------------------------------------------*
START-OF-SELECTION.

* Validate Transaction Code
SELECT SINGLE * FROM tstc
WHERE tcode EQ p_tcode.
* Find Repository Objects for transaction code
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 = enlfdir-area.
MOVE : tadir-devclass TO v_devclass.
ENDIF.
ENDIF.
* Find SAP Modifactions
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.
* Take the user to SMOD for the Exit that was selected.
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.

SAP ABAP - Sample Program To Send E-Mail.

REPORT ZMAIL.

TABLES: ekko.

PARAMETERS: p_email TYPE somlreci1-receiver .

TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
END OF t_ekpo.

DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
wa_ekpo TYPE t_ekpo.

TYPES: BEGIN OF t_charekpo,
ebeln(10) TYPE c,
ebelp(5) TYPE c,
aedat(8) TYPE c,
matnr(18) TYPE c,
END OF t_charekpo.

DATA: wa_charekpo TYPE t_charekpo.

DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.

DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.

DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.

*START_OF_SELECTION

START-OF-SELECTION.
* Retrieve sample data from table ekpo
PERFORM data_retrieval.

* Populate table with detaisl to be entered into .xls file
PERFORM build_xls_data_table.

*END-OF-SELECTION
END-OF-SELECTION.

* Populate message body text
perform populate_email_message_body.

* Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_message
it_attach
using p_email
'Example .xls documnet attachment'
'XLS'
'filename'
' '
' '
' '
changing gd_error
gd_reciever.

* Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM initiate_mail_execute_program.
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVAL
*&---------------------------------------------------------------------*
* Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------*
FORM data_retrieval.
SELECT ebeln ebelp aedat matnr
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekpo.
ENDFORM. " DATA_RETRIEVAL
*&---------------------------------------------------------------------*
*& Form BUILD_XLS_DATA_TABLE
*&---------------------------------------------------------------------*
* Build data table for .xls document
*----------------------------------------------------------------------*
FORM build_xls_data_table.
data: ld_store(50) type c. "Leading zeros

CONSTANTS: con_cret(5) TYPE c VALUE '0D', "OK for non Unicode
con_tab(5) TYPE c VALUE '09'. "OK for non Unicode

CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR' INTO it_attach SEPARATED
BY con_tab.

CONCATENATE con_cret it_attach INTO it_attach.

APPEND it_attach.

LOOP AT it_ekpo INTO wa_charekpo.
concatenate '=REPLACE("' wa_charekpo-ebelp '",1,5,"'
wa_charekpo-ebelp '")' into ld_store .
CONCATENATE wa_charekpo-ebeln ld_store wa_charekpo-aedat
wa_charekpo-matnr INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*&---------------------------------------------------------------------*
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
*&---------------------------------------------------------------------*
* Send email
*----------------------------------------------------------------------*
FORM send_file_as_email_attachment tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.


DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.

ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.


* Fill the document data.
w_doc_data-doc_size = 1.

* Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.

* Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = pit_attach[].

* Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.

* Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.

DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.

* Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.

* Populate zerror return code
ld_error = sy-subrc.

* Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.


*&---------------------------------------------------------------------*
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
*&---------------------------------------------------------------------*
* Instructs mail send program for SAPCONNECT to send email.
*----------------------------------------------------------------------*
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM


*&---------------------------------------------------------------------*
*& Form POPULATE_EMAIL_MESSAGE_BODY
*&---------------------------------------------------------------------*
* Populate message body text
*----------------------------------------------------------------------*
form populate_email_message_body.
REFRESH it_message.
it_message = 'Please find attached a list test ekpo records'.
APPEND it_message.
endform. " POPULATE_EMAIL_MESSAGE_BODY

ABAP - Simple ALV Interactive Report Program.

REPORT ZPURCHASE_ORDER.
*--type pools
TYPE-POOLS:SLIS.
*--internal tables for alv
DATA:
W_EBELN TYPE EKKO-EBELN,
W_PROG TYPE SY-REPID,
T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FS_FIELDCAT LIKE LINE OF T_FIELDCAT,
T_EVENTCAT TYPE SLIS_T_EVENT,
W_EVENTCAT LIKE LINE OF T_EVENTCAT.

DATA:
T_EKKO LIKE STANDARD TABLE OF EKKO,
FS_EKKO LIKE LINE OF T_EKKO.

DATA:T_EKPO LIKE STANDARD TABLE OF EKPO,
FS_EKPO LIKE LINE OF T_EKPO.

*---- SELECT-OPTIONS DECLARATION
SELECT-OPTIONS:S_EBELN FOR W_EBELN.

*----- START-OF-SELECTION
START-OF-SELECTION.
SELECT *
FROM EKKO
INTO TABLE T_EKKO
WHERE EBELN IN S_EBELN.

W_PROG = SY-REPID.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_PROG
I_CALLBACK_USER_COMMAND = 'PICK'
I_STRUCTURE_NAME = 'EKKO'
TABLES
T_OUTTAB = T_EKKO .

*&--------------------------------------------------------------------*
*& Form pick
*---------------------------------------------------------------------*
FORM PICK USING COMMAND LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
READ TABLE T_EKKO INTO FS_EKKO INDEX SELFIELD-TABINDEX.

CASE COMMAND.
WHEN '&IC1'.
SELECT *
FROM EKPO
INTO TABLE T_EKPO
WHERE EBELN EQ FS_EKKO-EBELN.

W_PROG = SY-REPID.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'EKPO'
CHANGING
CT_FIELDCAT = T_FIELDCAT .


DELETE T_FIELDCAT WHERE FIELDNAME EQ 'EBELN'.
DELETE T_FIELDCAT WHERE FIELDNAME EQ 'BUKRS'.
DELETE T_FIELDCAT WHERE FIELDNAME EQ 'LGORT'.
DELETE T_FIELDCAT WHERE FIELDNAME EQ 'WERKS'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_PROG
IT_FIELDCAT = T_FIELDCAT
IT_EVENTS = T_EVENTCAT
TABLES
T_OUTTAB = T_EKPO .

ENDCASE. " CASE COMMAND
ENDFORM. " FORM PICK

FORM T_EVENTCAT.
W_EVENTCAT-NAME = 'TOP_OF_PAGE'.
W_EVENTCAT-FORM = 'TOP'.
APPEND W_EVENTCAT TO T_EVENTCAT.
ENDFORM.

FORM TOP.
READ TABLE T_EKPO INTO FS_EKPO INDEX 1.
WRITE:/ 'Purchase Document Number'(001),30 FS_EKPO-EBELN,
/ 'Company Code'(002), 30 FS_EKPO-BUKRS,
/ 'Plant'(003), 30 FS_EKPO-WERKS,
/ 'Storage Location'(004),30 FS_EKPO-LGORT.
ENDFORM.


ALSO READ:

- Simple ALV Grid/List With Save Layout.

- Checkbox In ALV Program.

- ALV Header With Logo.

- Including Line After Subtotal In ALV Display.

..... Back To Index On ALV List/ Grid Display.

..... Back To MAIN INDEX.

ABAP - Time Difference Between Two Dates - Function Module SWI_DURATION_DETERMINE

REPORT ztest.

DATA : lv_seconds TYPE sytabix .

data: l type i ,
j(10) type c ,
k(12) type c .

parameters:p_date1 type sy-datum,
p_date2 type sy-datum.

CALL FUNCTION 'SWI_DURATION_DETERMINE'
EXPORTING
start_date = p_date1
end_date = p_date2
start_time = sy-uzeit
end_time = sy-uzeit
IMPORTING
duration = lv_seconds.

l = lv_seconds.
j = l / 60 .
k = l / 3600 .

WRITE :/ k ,'hours' .
write:/ j , 'minutes' .
write:/ l ,'seconds' .

ABAP - Convert Date Into Day Month Year In Words- CONVERSION_EXIT_LDATE_OUTPUT

report ztest .

DATA ldate(20).
CALL FUNCTION 'CONVERSION_EXIT_LDATE_OUTPUT'
EXPORTING
input = sy-datum
IMPORTING
OUTPUT = ldate.

write:/ ldate .

ABAP - Use Of CURSOR Keyword With Select Queries.

REPORT ZTEST_DWBLD1.

data: it_ekko like ekko occurs 5 with header line.

data: v_aedat type sy-datum.
DATA: dbcur TYPE cursor.

start-of-selection.

v_aedat = '20001102'.

OPEN CURSOR dbcur FOR
select * from ekko where aedat = '20001102'.

do.
FETCH NEXT CURSOR dbcur INTO table it_ekko package size 5.

if sy-subrc <> 0.
close cursor dbcur.
exit.
else.

loop at it_ekko.
write: / it_ekko-ebeln.
endloop.
refresh it_ekko.
endif.
enddo.

ABAP - Sample Program On Adding Colors In ALV Report Program.

REPORT zdemo_alvgrid .

TABLES: ekko.

type-pools: slis. "ALV Declarations

*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
line_color(4) type c, "Used to store row color attributes
END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.

*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.

*Start-of-selection.
START-OF-SELECTION.

perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.

*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
form build_fieldcatalog.

fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG


*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
* Build layout for ALV grid report
*----------------------------------------------------------------------*
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-info_fieldname = 'LINE_COLOR'.
endform. " BUILD_LAYOUT

*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
* Display report using ALV grid
*----------------------------------------------------------------------*
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_ekko .

endform. " DISPLAY_ALV_REPORT


*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVAL
*&---------------------------------------------------------------------*
* Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------*
form data_retrieval.
data: ld_color(1) type c.

select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.

*Populate field with color attributes
loop at it_ekko into wa_ekko.
ld_color = ld_color + 1.
* Only 7 colours so need to reset color value
if ld_color = 8.
ld_color = 1.
endif.
concatenate 'C' ld_color '10' into wa_ekko-line_color.
modify it_ekko from wa_ekko.
endloop.
endform. " DATA_RETRIEVAL


ALSO READ:

- Simple ALV Grid/List With Save Layout.

- Checkbox In ALV Program.

- ALV Header With Logo.

- Including Line After Subtotal In ALV Display.

..... Back To Index On ALV List/ Grid Display.

..... Back To MAIN INDEX.


ABAP - Convert Amount Into Words Using HR_IN_CHG_INR_WRDS

data: word(40) type c.

CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
EXPORTING
AMT_IN_NUM = '10000078'
IMPORTING
AMT_IN_WORDS = word.

write:/ word.

ABAP - Fetch Date By Adding Two Time Using ADD_TIME_TO_DATE

report .

data: i_date like SY-DATUM ,
date like SY-DATUM .

i_date = sy-datum .

CALL FUNCTION 'ADD_TIME_TO_DATE'
EXPORTING
I_IDATE = i_date "Original date
I_TIME = '1' " Ammount to add
I_IPRKZ = '3' " unit: 'blank'-days 1-weeks 2-months 3-years
* I_RDMHD =
IMPORTING
O_IDATE = date ."new date

write:/ date .

ABAP - Simple ALV Grid/List With Save Layout.

REPORT ZTEST.

TYPE-POOLS: slis.

DATA: report_id LIKE sy-repid.

DATA: i_qmel LIKE qmel OCCURS 0.

DATA: i_layout TYPE slis_layout_alv.

SELECT * FROM qmel INTO TABLE i_qmel.

report_id = sy-repid.

PERFORM f1000_layout_init CHANGING i_layout.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = report_id
i_structure_name = 'QMEL'
is_layout = i_layout
i_save = 'A'
TABLES
t_outtab = i_qmel .

FORM f1000_layout_init USING
i_layout TYPE slis_layout_alv.
CLEAR i_layout.

i_layout-colwidth_optimize = 'X'.

ENDFORM.




ABAP - Fetch Last Day Of Any Month Using FIMA_DATE_CREATE

report ztest .

data:lv_actual_date type sy-datum,
lv_end_of_month_date type sy-datum.

parameters:p_date type dats.

lv_actual_date = p_date.

CALL FUNCTION 'FIMA_DATE_CREATE'
EXPORTING
I_DATE = lv_actual_date
* I_FLG_END_OF_MONTH = ' '
* I_YEARS = 0
* I_MONTHS = 0
* I_DAYS = 0
* I_CALENDAR_DAYS = 0
I_SET_LAST_DAY_OF_MONTH = 'X'
IMPORTING
E_DATE = lv_end_of_month_date .

write: / lv_end_of_month_date.

ABAP : F4 Help (Value On Request) For Month And Year.

REPORT ZPOPDATE.

DATA: V_CODE LIKE SY-SUBRC.

PARAMETER: V_MONTH LIKE ISELLIST-MONTH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR V_MONTH.

CALL FUNCTION 'POPUP_TO_SELECT_MONTH'
EXPORTING
ACTUAL_MONTH = '200205'
LANGUAGE = SY-LANGU
START_COLUMN = 8
START_ROW = 5
IMPORTING
SELECTED_MONTH = V_MONTH
RETURN_CODE = V_CODE
EXCEPTIONS
FACTORY_CALENDAR_NOT_FOUND = 1
HOLIDAY_CALENDAR_NOT_FOUND = 2
MONTH_NOT_FOUND = 3
OTHERS = 4.


ALSO READ:

- Printing The Selection Screen Data On The Report Program.

- Changing Selection Screen Design Through Tcode SE51.

- F4 (Value On Request) On Field BUKRS On Selection Screen.

- F4 (Value On Request) On Logical File On selection Screen.

- Display Icon On Selection Screen.

ABAP - Convert Any Number Into Words Using 'SPELL_AMOUNT'

report ztest .

parameters: v_int TYPE i .

DATA words LIKE SPELL.

CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = v_int
LANGUAGE = SY-LANGU
IMPORTING
IN_WORDS = words
.
WRITE words-word.

ABAP - Sample Program To Open A File On The System Using FM WS_EXECUTE.

REPORT ZUM_OPEN_WORD .

* The internal table is declared of size 3
DATA: BEGIN OF ITAB OCCURS 3,
LINE(50),
END OF ITAB.

PARAMETERS: PROG(70) DEFAULT
'C:\Program Files\Microsoft Office\Office\WINWORD.EXE'.
PARAMETERS: FILE1(70) DEFAULT 'C:\TEMP\TEST.TXT'.
* Tick to print the Text file after saving from MS WORDS
PARAMETERS: S_UP AS CHECKBOX.
* Tick to create new or overwrite Text file
PARAMETERS: S_NEW AS CHECKBOX.

IF S_UP = 'X'.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'FILE1'
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_OPEN_ERROR = 1.

IF SY-SUBRC = 0.
LOOP AT ITAB.
WRITE: / ITAB.
ENDLOOP.
ELSE.
WRITE: / 'File open error.'.
ENDIF.
ELSE.
IF S_NEW = 'X'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'FILE1'
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
OTHERS = 5.
ENDIF.

CASE SY-SUBRC.
WHEN 1.
WRITE: / 'GUI DOWNLOAD FILE WRITE ERROR'.
WHEN 2.
WRITE: / 'GUI DOWNLOAD NO BATCH'.
WHEN 3.
WRITE: / 'GUI DOWNLOAD GUI REFUSE FILETRANSFER'.
WHEN 4.
WRITE: / 'GUI DOWNLOAD INVALID TYPE'.
WHEN 5.
WRITE: / 'GUI DOWNLOAD OTHERS'.
ENDCASE.

CALL FUNCTION 'WS_EXECUTE'
EXPORTING
PROGRAM = PROG
COMMANDLINE = 'FILE1'
INFORM = ' '
EXCEPTIONS
FRONTEND_ERROR = 1
NO_BATCH = 2
PROG_NOT_FOUND = 3
ILLEGAL_OPTION = 4
GUI_REFUSE_EXECUTE = 5
OTHERS = 6.

CASE SY-SUBRC.
WHEN 1.
WRITE: / 'FRONTEND ERROR'.
WHEN 2.
WRITE: / 'NO BATCH'.
WHEN 3.
WRITE: / 'PROGRAM NOT FOUND'.
WHEN 4.
WRITE: / 'ILLEGA OPTION'.
WHEN 5.
WRITE: / 'GUI REFUSE EXECUTE'.
WHEN 6.
WRITE: / 'OTHERS'.
ENDCASE.
ENDIF.

ALSO READ:

- Download Code To System Using FM RS_TESTFRAME_CALL.

- Download Code To The Desktop With Screens.

- Uploading Data From Excel Sheet To Internal Table Using FM ALSM_EXCEL_TO_INTERNAL_TABLE.

- Uploading Images From PC To An Internal Table Using FM BDS_BUSINESSDOCUMENT_CREATEF.

- Uploading Data To The FTP Server Using FM GUI_UPLOAD And FILE_GET_NAME.


RETURN TO MAIN INDEX:

- Sample Programs On Uploading & Downloading Files.

- Sample Programs On HR ABAP.

- Sample Report Programs On ALV List/ Grid Display.

- Sample Programs On Selection Screen.

- Sample Programs On BDC.

.....Back To MAIN INDEX.

ABAP - Convert Month To Words Using 'CONVERSION_EXIT_LDATE_OUTPUT'

REPORT ZMONTH.

DATA X_MONTH(11).

parameters:p_date type sy-datum.


CALL FUNCTION 'CONVERSION_EXIT_LDATE_OUTPUT'
EXPORTING
INPUT = p_date
IMPORTING
OUTPUT = X_MONTH.

WRITE:/ 'Month ', X_MONTH+3(8).

ABAP - Example On Modifying Internal Table.

report ztest .

tables:mara,marc,mard.
data:begin of it_final occurs 0,
matnr like mara-matnr,
mtart like mara-mtart,
meins like mara-meins,
werks like marc-werks,
pstat like marc-pstat,
lgort like mard-lgort,
labst like mard-labst,
end of it_final.

select-options:s_matnr for mara-matnr.
start-of-selection.
select matnr
mtart
meins
from mara
into table it_final
where matnr in s_matnr.
if sy-subrc = 0.
loop at it_final.
select single
werks
pstat
from marc
into (it_final-werks,it_final-pstat)
where matnr = it_final-matnr.
modify it_final.
if sy-subrc = 0.
select single
lgort
labst
from mard
into (it_final-lgort,it_final-labst)
where werks = it_final-werks.
modify it_final.
endif.
endloop.
endif.

if sy-subrc = 0.
loop at it_final.
write:/ it_final-matnr,
it_final-mtart,
it_final-meins,
it_final-werks,
it_final-pstat,
it_final-lgort,
it_final-labst.
endloop.
endif.

ABAP - Logical Databse Without Macros.

REPORT ZTEST .

TABLES pernr.

INFOTYPES : 0001.

START-OF-SELECTION.

GET pernr.

WRITE : / 'Result from Macros'.

rp-provide-from-frst p0001 space pn-begda pn-endda.

IF pnp-sw-found = 1.

WRITE : / '-------------------------------------'.

WRITE : / 'Result from rp-provide-from-frst'.

WRITE : / '-------------------------------------'.

WRITE : / p0001-pernr, p0001-begda, p0001-endda.

ENDIF.

rp-provide-from-last p0001 space pn-begda pn-endda.

IF pnp-sw-found = 1.

WRITE : / '-------------------------------------'.

WRITE : / 'Result from rp-provide-from-last'.

WRITE : / '-------------------------------------'.

WRITE : / p0001-pernr, p0001-begda, p0001-endda.

ENDIF.

rp-read-infotype pernr-pernr 0001 p0001 pn-begda pn-endda.

IF pnp-sw-found = 1.

WRITE : / '-------------------------------------'.

WRITE : / 'Result from rp-read-infotype'.

WRITE : / '-------------------------------------'.

LOOP AT p0001.

WRITE : / p0001-pernr, p0001-begda, p0001-endda.

ENDLOOP.

ENDIF.

END-OF-SELECTION.

ABAP - ListBox From User Values In Selection Screen.

report ztest.

TYPE-POOLS: VRM.
DATA: NAME TYPE VRM_ID,
LIST TYPE VRM_VALUES,
VALUE LIKE LINE OF LIST.

PARAMETERS: PS_PARM(10) AS LISTBOX VISIBLE LENGTH 10.

AT SELECTION-SCREEN OUTPUT.

NAME = 'PS_PARM'.
VALUE-KEY = '1'.
VALUE-TEXT = 'LINE 1'.
APPEND VALUE TO LIST.

VALUE-KEY = '2'.
VALUE-TEXT = 'LINE 2'.
APPEND VALUE TO LIST.

VALUE-KEY = '3'.
VALUE-TEXT = 'LINE 3'.
APPEND VALUE TO LIST.

VALUE-KEY = '4'.
VALUE-TEXT = 'LINE 4'.
APPEND VALUE TO LIST.

VALUE-KEY = '5'.
VALUE-TEXT = 'LINE 5'.
APPEND VALUE TO LIST.

VALUE-KEY = '6'.
VALUE-TEXT = 'LINE 6'.
APPEND VALUE TO LIST.

VALUE-KEY = '7'.
VALUE-TEXT = 'LINE 7'.
APPEND VALUE TO LIST.

CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = NAME
VALUES = LIST.

START-OF-SELECTION.
WRITE: / 'PARAMETER:', PS_PARM.



ABAP - Simple Logical Database Report Program.

TABLES:PERNR.
INFOTYPES:0002,0008.
GET PERNR.
PROVIDE * FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA.
ENDPROVIDE.
PROVIDE * FROM P0008 BETWEEN PN-BEGDA AND PN-ENDDA.
ENDPROVIDE.

IF SY-SUBRC = 0.
WRITE:/ P0002-PERNR,
P0002-BEGDA,
P0002-ENDDA,
P0002-VORNA,
P0008-ANSAL,
P0008-lga01,
P0008-bet01,
P0008-PREAS.
ENDIF.

ABAP - Using Inner Join To Fetch Data From Header & Item Level Tables.

REPORT ZTEST .
tables:mara,marc,mard.
data:begin of itab occurs 0,
matnr like mara-matnr,
mtart like mara-mtart,
meins like mara-meins,
werks like marc-werks,
pstat like marc-pstat,
labst like mard-labst,
lgort like mard-lgort,
maktx like makt-maktx,
end of itab.


select-options:s_matnr for mara-matnr.

start-of-selection.
select a~matnr
a~mtart
a~meins
b~werks
b~pstat
c~lgort
c~labst
into corresponding fields of table itab
from mara as a inner join marc as b on a~matnr = b~matnr
inner join mard as c on a~matnr = c~matnr
and b~werks = c~werks
where a~matnr in s_matnr.

if sy-subrc = 0.
loop at itab.
select single maktx
from makt
into itab-maktx
where matnr = itab-matnr.
modify itab.

write:/ itab-matnr,
itab-mtart,
itab-meins,
itab-werks,
itab-pstat,
itab-lgort,
itab-labst,
itab-maktx.
endloop.