HR Payslip Internal Table
Hi ABAPERS,
I am working on the HR Payslip in PE51. Does anyone know which internal table stores the Earnings and Deductions that are displayed on the HR Payslip? It seems it is not the RT table that contains these. In fact, RT contains the results split according to my requirement as below, but the value displayed on the payslip is a cumulative value. I need to manipulate this table so that I can split the deduction for life assurance policy for that employee into the individual policies from the same life assurance third party. E.g.
life assurance XYZ (wage type 2093)
Policy1 344556 R45.00
Policy2 746737 R65.00
Policy3 667889 R50.00
At the moment it accumulates the deduction as follows:
Life assurance XYZ (wage type 2093)
Policy R160
Regards
Edited by: Darlington Chiyamha on Jun 9, 2011 9:33 AM
Subu,
apparently this is not the right place to ask. It's more related to SQL or PL/SQL.
Anyway, your hr schema has defined (don't ask me how as this is not normal) a constraint which is in disabled state and thus preventing insert of any record.
You can either enable the constraint or drop it (if you don't nee it)
--Enable constraint
alter table employees modify constraint HR.EMP_EMAIL_NN enable validate;Timo
Similar Messages
-
How to Send Internal table to SAP Spool using Function Modules or Methods?
Hi Experts,
How to Send Internal table to SAP Spool using Function Modules or Methods?
Thanks ,
KiranThis is my code.
I still get the no ABAP list data for the spool, even tho I can see it sp01?
REPORT Z_MAIL_PAYSLIP.
* Declaration Part *
tables: PERNR, PV000, T549Q, V_T514D, HRPY_RGDIR.
infotypes: 0000, 0001, 0105, 0655.
data: begin of ITAB occurs 0,
MTEXT(25) type C,
PERNR like PA0001-PERNR,
ABKRS like PA0001-ABKRS,
ENAME like PA0001-ENAME,
USRID_LONG like PA0105-USRID_LONG,
end of ITAB.
data: W_BEGDA like HRPY_RGDIR-FPBEG,
W_ENDDA like HRPY_RGDIR-FPEND.
data: RETURN like BAPIRETURN1 occurs 0 with header line.
data: P_INFO like PC407,
P_FORM like PC408 occurs 0 with header line.
data: P_IDX type I,
MY_MONTH type T549Q-PABRP,
STR_MY_MONTH(2) type C,
MY_YEAR type T549Q-PABRJ,
STR_MY_YEAR(4) type C,
CRLF(2) type x value '0D0A'.
data: W_CMONTH(10) type C.
data: TAB_LINES type I,
ATT_TYPE like SOODK-OBJTP.
data: begin of P_INDEX occurs 0,
INDEX type I,
end of P_INDEX.
constants: begin of F__LTYPE, "type of line
CMD like PC408-LTYPE value '/:', "command
TXT like PC408-LTYPE value 's', "textline
end of F__LTYPE.
constants: begin of F__CMD, "commands
NEWPAGE like PC408-LINDA value '',
end of F__CMD.
data: P_LIST like ABAPLIST occurs 1 with header line.
*data: OBJBIN like SOLISTI1 occurs 10 with header line,
data: OBJBIN like LVC_S_1022 occurs 10 with header line,
DOCDATA like SODOCCHGI1,
OBJTXT like SOLISTI1 occurs 10 with header line,
OBJPACK like SOPCKLSTI1 occurs 1 with header line,
RECLIST like SOMLRECI1 occurs 1 with header line,
OBJHEAD like SOLISTI1 occurs 1 with header line,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_buffer type string,
l_no_of_bytes TYPE i,
l_pdf_spoolid LIKE tsp01-rqident,
l_jobname LIKE tbtcjob-jobname.
data: file_length type int4,
spool_id type rspoid,
line_cnt type i.
*-------------------------------------------------------------------* * INITIALIZATION *
OBJBIN = ' | '.
append OBJBIN.
OBJPACK-HEAD_START = 1.
data: S_ABKRS like PV000-ABKRS.
data: S_PABRP like T549Q-PABRP.
data: S_PABRJ like T549Q-PABRJ.
* SELECTION SCREEN *
selection-screen begin of block BL1.
parameters: PAY_VAR like BAPI7004-PAYSLIP_VARIANT default 'ESS_PAYSLIPS' obligatory.
selection-screen end of block BL1.
START-OF-SELECTION.
s_ABKRS = PNPXABKR.
S_PABRP = PNPPABRP.
s_pabrj = PNPPABRJ.
w_begda = PN-BEGDA.
w_endda = PN-ENDDA.
get pernr.
* "Check active employees
rp-provide-from-last p0000 space pn-begda pn-endda.
CHECK P0000-STAT2 IN PNPSTAT2.
* "Check Payslip Mail flag
rp-provide-from-last p0655 space pn-begda pn-endda.
CHECK P0655-ESSONLY = 'X'.
rp-provide-from-last p0001 space pn-begda pn-endda.
* "Find email address
RP-PROVIDE-FROM-LAST P0105 '0030' PN-BEGDA PN-ENDDA.
if p0105-usrid_LONG ne ''.
ITAB-PERNR = P0001-PERNR.
ITAB-ABKRS = P0001-ABKRS.
ITAB-ENAME = P0001-ENAME.
ITAB-USRID_LONG = P0105-USRID_LONG.
append itab.
clear itab.
endif.
"SY-UCOMM ='ONLI'
END-OF-SELECTION.
*------------------------------------------------------------------* start-of-selection.
write : / 'Payroll Area : ', S_ABKRS.
write : / 'Payroll Period/Year : ',STR_MY_MONTH,'-',STR_MY_YEAR. write : / 'System Date : ', SY-DATUM.
write : / 'System Time : ', SY-UZEIT.
write : / 'User Name : ', SY-UNAME.
write : / SY-ULINE.
sort ITAB by PERNR.
loop at ITAB.
clear : P_INFO, P_FORM, P_INDEX, P_LIST, OBJBIN, DOCDATA, OBJTXT, OBJPACK, RECLIST, TAB_LINES.
refresh : P_FORM, P_INDEX, P_LIST, OBJBIN, OBJTXT, OBJPACK, RECLIST.
* Retrieve Payroll results sequence number for this run
select single * from HRPY_RGDIR where PERNR eq ITAB-PERNR
and FPBEG ge W_BEGDA
and FPEND le W_ENDDA
and SRTZA eq 'A'.
* Produce payslip for those payroll results
if SY-SUBRC = 0.
call function 'GET_PAYSLIP'
EXPORTING
EMPLOYEE_NUMBER = ITAB-PERNR
SEQUENCE_NUMBER = HRPY_RGDIR-SEQNR
PAYSLIP_VARIANT = PAY_VAR
IMPORTING
RETURN = RETURN
P_INFO = P_INFO
TABLES
P_FORM = P_FORM.
check RETURN is initial.
* remove linetype from generated payslip
loop at p_form.
objbin = p_form-linda.
append objbin.
line_cnt = line_cnt + 1.
endloop.
file_length = line_cnt * 1022.
* create spool file of paylsip
CALL FUNCTION 'SLVC_TABLE_PS_TO_SPOOL'
EXPORTING
i_file_length = file_length
IMPORTING
e_spoolid = spool_id
TABLES
it_textdata = objbin.
IF sy-subrc EQ 0.
WRITE spool_id.
ENDIF.
DESCRIBE table objbin.
DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = spool_id
NO_DIALOG = ' '
DST_DEVICE = 'MAIL'
* PDF_DESTINATION =
* IMPORTING
* PDF_BYTECOUNT = l_no_of_bytes
* PDF_SPOOLID = l_pdf_spoolid
* LIST_PAGECOUNT =
* BTC_JOBNAME =
* BTC_JOBCOUNT =
TABLES
PDF = pdf
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DESTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*Download PDF file C Drive
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\itab_to_pdf.pdf'
filetype = 'BIN'
TABLES
data_tab = pdf.
* Transfer the 132-long strings to 255-long strings
* LOOP AT pdf.
* TRANSLATE pdf USING ' ~'.
* CONCATENATE gd_buffer pdf INTO gd_buffer.
* ENDLOOP.
* TRANSLATE gd_buffer USING '~ '.
* DO.
* it_mess_att = gd_buffer.
* APPEND it_mess_att.
* SHIFT gd_buffer LEFT BY 255 PLACES.
* IF gd_buffer IS INITIAL.
* EXIT.
* ENDIF.
* ENDDO.
OBJHEAD = 'Objhead'.
append OBJHEAD.
* preparing email subject
concatenate W_ENDDA(6)
' Payslip-'
ITAB-ENAME+0(28)
ITAB-PERNR+4(4) ')'
into DOCDATA-OBJ_DESCR.
DOCDATA-OBJ_NAME = 'Pay Slip'.
DOCDATA-OBJ_LANGU = SY-LANGU.
OBJTXT = 'Pay Slip.'.
append OBJTXT.
*prepare email lines
OBJTXT = DOCDATA-OBJ_DESCR.
append OBJTXT.
OBJTXT = 'Please find enclosed your current payslip.'.
append OBJTXT.
* Write Attachment(Main)
* 3 has been fixed because OBJTXT has fix three lines
read table OBJTXT index 3.
* DOCDATA-DOC_SIZE = ( 3 - 1 ) * 255 + strlen( OBJTXT ).
clear OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = 3.
OBJPACK-DOC_TYPE = 'RAW'.
append OBJPACK.
* Create Message Attachment
ATT_TYPE = 'PDF'.
describe table OBJBIN lines TAB_LINES.
read table OBJBIN index TAB_LINES.
* OBJPACK-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + strlen( OBJBIN ).
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = ATT_TYPE.
OBJPACK-OBJ_NAME = 'ATTACHMENT'.
OBJPACK-OBJ_DESCR = 'Payslip'.
append OBJPACK.
* Create receiver list refresh RECLIST.
clear RECLIST.
RECLIST-RECEIVER = itab-USRID_long.
translate RECLIST-RECEIVER to lower case.
RECLIST-REC_TYPE = 'U'.
append RECLIST.
* Send the document
*SO_NEW_DOCUMENT_ATT_SEND_API1
call function 'SO_DOCUMENT_SEND_API1'
exporting
DOCUMENT_DATA = DOCDATA
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
tables
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = pdf
CONTENTS_TXT = OBJTXT
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
RECEIVERS = RECLIST
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.
if SY-SUBRC NE 0.
ITAB-MTEXT = 'Message Not Sent to : '.
else.
ITAB-MTEXT = 'Message Sent to : '.
endif.
* else.
* ITAB-MTEXT = 'Message Not Sent to : '.
* endif.
else.
"SY-SUBRC Not = 0
ITAB-MTEXT = 'Payroll data not found : '.
endif.
"end of SY-SUBRC = 0.
modify ITAB.
endloop. "end loop at ITAB
sort ITAB by MTEXT PERNR.
loop at ITAB.
at new MTEXT.
uline.
write : / ITAB-MTEXT color 4 intensified on.
write : / 'Emp. Code' color 2 intensified on,
12 'Emp. Name' color 2 intensified on,
54 'Email ID' color 2 intensified on.
endat.
write : / ITAB-PERNR, 12 ITAB-ENAME, 54 ITAB-USRID_LONG.
endloop. -
Sy-tabix for internal table in smartform
Hi friends,
How to capture the sy-tabix value for the entries in an internal table which has been looped into the loop of table node of a smartform?? I need to print something immedaitely after the end of the table
For every record the value of sy-tabix is showing 1 !!
Advance Thanks
AadarshHi Aadarsh,
Give ur sy-tabix at the end of the loop.
loop at itab.
//table node populations.
endloop.
give a seperate loop for this.
loop at itab.
sy-tabix.
endloop
get the total no and print it after the table.
If u r using do loop then give sy-index.
Hope tihs helps u,
Regards,
Nagarajan.
Message was edited by: Nagarajan Kumarappan -
Regarding Exporting and Importing internal table
Hello Experts,
I have two programs:
1) Main program: It create batch jobs through open_job,submit and close job.Giving sub program as SUBMIT.
I am using Export IT to memory id 'MID' to export internal table data to sap memory in the subprogram.
The data will be processed in the subprogram and exporting data to sap memory.I need this data in the main program(And using import to get the data,but it is not working).
Importing IT1 from memory id 'MID' to import the table data in the main program after completing the job(SUBMIT SUBPROGRAM AND RETURN).
Importing is not getting data to internal table.
Can you please suggest something to solve this issue.
Thank you.
Regards,
Anand.Hi,
This is the code i am using.
DO g_f_packets TIMES.
* Start Immediately
IF NOT p_imm IS INITIAL .
g_flg_start = 'X'.
ENDIF.
g_f_jobname = 'KZDO_INHERIT'.
g_f_jobno = g_f_jobno + '001'.
CONCATENATE g_f_jobname g_f_strtdate g_f_jobno INTO g_f_jobname
SEPARATED BY '_'.
CONDENSE g_f_jobname NO-GAPS.
p_psize1 = p_psize1 + p_psize.
p_psize2 = p_psize1 - p_psize + 1.
IF p_psize2 IS INITIAL.
p_psize2 = 1.
ENDIF.
g_f_spname = 'MID'.
g_f_spid = g_f_spid + '001'.
CONDENSE g_f_spid NO-GAPS.
CONCATENATE g_f_spname g_f_spid INTO g_f_spname.
CONDENSE g_f_spname NO-GAPS.
* ... (1) Job creating...
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = g_f_jobname
IMPORTING
jobcount = g_f_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE e469(9j) WITH g_f_jobname.
ENDIF.
* (2)Report start under job name
SUBMIT (g_c_prog_kzdo)
WITH p_lgreg EQ p_lgreg
WITH s_grvsy IN s_grvsy
WITH s_prvsy IN s_prvsy
WITH s_prdat IN s_prdat
WITH s_datab IN s_datab
WITH p1 EQ p1
WITH p3 EQ p3
WITH p4 EQ p4
WITH p_mailid EQ g_f_mailid
WITH p_psize EQ p_psize
WITH p_psize1 EQ p_psize1
WITH p_psize2 EQ p_psize2
WITH spid EQ g_f_spid
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
VIA JOB g_f_jobname NUMBER g_f_jobcount AND RETURN.
*(3)Job closed when starts Immediately
IF NOT p_imm IS INITIAL.
IF sy-index LE g_f_nojob.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = g_f_jobcount
jobname = g_f_jobname
strtimmed = g_flg_start
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
gs_jobsts-jobcount = g_f_jobcount.
gs_jobsts-jobname = g_f_jobname.
gs_jobsts-spname = g_f_spname.
APPEND gs_jobsts to gt_jobsts.
ELSEIF sy-index GT g_f_nojob.
CLEAR g_f_flg.
DO. " Wiating untill any job completion
LOOP AT gt_jobsts into gs_jobsts.
CLEAR g_f_status.
CALL FUNCTION 'BP_JOB_STATUS_GET'
EXPORTING
JOBCOUNT = gs_jobsts-jobcount
JOBNAME = gs_jobsts-jobname
IMPORTING
STATUS = g_f_status
* HAS_CHILD =
* EXCEPTIONS
* JOB_DOESNT_EXIST = 1
* UNKNOWN_ERROR = 2
* PARENT_CHILD_INCONSISTENCY = 3
* OTHERS = 4
g_f_mid = gs_jobsts-spname.
IF g_f_status = 'F'.
IMPORT gt_final FROM MEMORY ID g_f_mid .
FREE MEMORY ID gs_jobsts-spname.
APPEND LINES OF gt_final to gt_final1.
REFRESH gt_prlist.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = g_f_jobcount
jobname = g_f_jobname
strtimmed = g_flg_start
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc = 0.
g_f_flg = 'X'.
gs_jobsts1-jobcount = g_f_jobcount.
gs_jobsts1-jobname = g_f_jobname.
gs_jobsts1-spname = g_f_spname.
APPEND gs_jobsts1 TO gt_jobsts.
DELETE TABLE gt_jobsts FROM gs_jobsts.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
IF g_f_flg = 'X'.
CLEAR g_f_flg.
EXIT.
ENDIF.
ENDDO.
ENDIF.
ENDIF.
IF sy-subrc <> 0.
MESSAGE e539(scpr) WITH g_f_jobname.
ENDIF.
COMMIT WORK .
ENDDO. -
How to select the data from a Maintainance View into an internal table
Hi All,
Can anybody tell me how to select the data from a Maintainance View into an internal table.
Thanks,
srinivas.HI,
You can not retrieve data from A mentenance view.
For detail check this link,
http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ed2d446011d189700000e8322d00/content.htm
Regards,
Anirban -
Creating XML file from ABAP internal table data....
Hello,
I am fethcing data froma custom table and I have to write data in XMl format. Following is the XML format in which I want data. Is there any function module iN SAP which will help me in writing data from internal table to XML file ?
<batch>
<invoice>
<StatusCode>10</StatusCode>
<paymentamount>122.00</paymentamount>
<ReferenceNumber>70980934</ReferenceNumber>
</invoice>
<invoice>
<StatusCode>90</StatusCode>
<paymentamount>122.00</paymentamount>
<ReferenceNumber>70980934</ReferenceNumber>
</invoice>
<control>
<InvoiceCount>2</InvoiceCount>
</control>
</batch>
Please help.
Regards,
Jainam.I suggest you look into "simple transformations". That's SAP's most recent technology for such purposes, as far as I know.
http://help.sap.com/abapdocu_70/en/ABENABAP_ST.htm
Thomas -
Need suggestion in uploading dynamic excel file to corresponding columns of internal table
Hi Friends,
I have an excel file which doesn't have standard template. Just the users will key in their header (in row1 ) and followed by item details in excel and upload to internal table. Now by doing some internal developments in program I need to place the values in corresponding fields.
Let me explain with some examples.
1. I have an internal table
data : begin of itab occurs 0,
f1,
f2,
f3,
f4,
f5,
end of itab.
2. I have excel file as below
3 . Now i need to fill my internal table itab as below
Need to be placed in corresponding fields.
4. When I used GUI_UPLOAD FM it updates internal table as
Please give me suggestion on how to achieve it.
Thanks in advance.Hi Kumar,
use a temporary table to get excel values and then parse them to a second table with the format you want.
This is pretty basic.
regards,
Edgar -
How to populate data in dynamic internal table
Hi Expert,
fyi. My dynamic internal table field is created base on data selected. Eg. select table qpcd has 5 records. These 5 recods will become fieldname to my dynamic internal table. My dynamic internal table will be
...itab
01
02
03
04
05
The 5 records from qpcd is populated in another table call viqmel. I need to find the occurance of each code in viqmel and populate the number of occurance in itab in each of column. The final dynamic itab will be like this
table itab
01 02 03 04 05 -
> field name
2 0 1 0 1 -
> data
my source code like below
Report ZPLYGRND2.
TABLES: mara, makt.
TYPE-POOLS: slis, sydes.
DATA:it_fcat TYPE slis_t_fieldcat_alv,
is_fcat LIKE LINE OF it_fcat,
ls_layout TYPE slis_layout_alv.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
DATA: new_table TYPE REF TO data,
new_line TYPE REF TO data,
ob_cont_alv TYPE REF TO cl_gui_custom_container,
ob_alv TYPE REF TO cl_gui_alv_grid,
vg_campos(255) TYPE c,
i_campos LIKE TABLE OF vg_campos,
vg_campo(30) TYPE c,
vg_tables(60) TYPE c.
types : begin of t_qpcd,
codegruppe like qpcd-codegruppe,
code like qpcd-code,
end of t_qpcd.
data:wa_qpcd type t_qpcd,
i_qpcd type standard table of t_qpcd initial size 0.
FIELD-SYMBOLS: <l_table> TYPE table,
<l_line> TYPE ANY,
<l_field> TYPE ANY.
select * into corresponding fields of wa_qpcd from qpcd
where katalogart = 'D'
and codegruppe = 'OOT01'.
append wa_qpcd to i_qpcd.
endselect.
loop at i_qpcd into wa_qpcd.
is_fcat-fieldname = wa_qpcd-code.
APPEND is_fcat TO it_fcat.
endloop.
LOOP AT it_fcat INTO is_fcat.
is_fieldcat-fieldname = is_fcat-fieldname.
is_fieldcat-ref_field = is_fcat-ref_fieldname.
is_fieldcat-ref_table = is_fcat-ref_tabname.
APPEND is_fieldcat TO it_fieldcat.
ENDLOOP.
*... Create the dynamic internal table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
if sy-subrc = 0.
endif.
*... Create a new line
ASSIGN new_table->* TO <l_table>.
CREATE DATA new_line LIKE LINE OF <l_table>.
ASSIGN new_line->* TO <l_line>.
LOOP AT <l_table> INTO <l_line>.
ENDLOOP.hello dear i m giving u a code in this a dynamic table is made on the basis of table in database , and u can download this data correct it , see it, or even change it....and upload in tht table help full if u dont know the table name...in advance.
also the code to populate data in dynamic table is in this code like:
SELECT * FROM (MTABLE_N)
INTO CORRESPONDING FIELDS OF TABLE <FS_ITAB> .
look at the whole program .hope this solve ur problem thanks.
REPORT ZTESTA MESSAGE-ID ZIMM .
TYPES : DATA_OBJECT TYPE REF TO DATA.
DATA : MITAB TYPE REF TO DATA .
TYPE-POOLS : SLIS .
DATA : IT_FIELDCAT TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV
WITH HEADER LINE .
DATA : IT_FIELDCATALOG TYPE LVC_T_FCAT .
DATA : WA_FIELDCATALOG TYPE LVC_S_FCAT .
DATA : I_STRUCTURE_NAME LIKE DD02L-TABNAME .
DATA : I_CALLBACK_PROGRAM LIKE SY-REPID .
DATA : DYN_LINE TYPE DATA_OBJECT .
FIELD-SYMBOLS : <FS_ITAB> TYPE STANDARD TABLE .
DATA : TABLE_NAME_IS_VALID TYPE C .
DATA : DYNAMIC_IT_INSTANTIATED TYPE C .
CONSTANTS BUTTONSELECTED TYPE C VALUE 'X' .
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) T_TABL.
PARAMETERS : MTABLE_N LIKE RSRD1-TBMA_VAL
MATCHCODE OBJECT DD_DBTB_16 OBLIGATORY .
DATA CHECKTABLED.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) T_FILE.
PARAMETERS : MFILENAM LIKE RLGRAP-FILENAME .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) T_DOWN.
PARAMETERS : P_DOWNLD RADIOBUTTON GROUP GRP1
USER-COMMAND M_UCOMM .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) T_CHKF.
PARAMETERS : P_CHKFIL RADIOBUTTON GROUP GRP1 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) T_UPLD.
PARAMETERS : P_UPLOAD RADIOBUTTON GROUP GRP1 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) T_SHOW.
PARAMETERS : P_SHOW_T RADIOBUTTON GROUP GRP1 .
SELECTION-SCREEN END OF LINE.
AT SELECTION-SCREEN OUTPUT .
PERFORM CHECK_FILENAME .
AT SELECTION-SCREEN.
IF SY-UCOMM = 'ONLI'.
CHECKTABLED = MTABLE_N+0(1).
IF CHECKTABLED NE 'Z'.
MESSAGE I017.
LEAVE TO SCREEN 1000.
ENDIF.
IF SY-UNAME NE 'KAMESH.K'.
MESSAGE I023 WITH SY-UNAME.
LEAVE TO SCREEN 1000.
ENDIF.
ENDIF.
IF SY-UCOMM = 'PRIN'.
CHECKTABLED = MTABLE_N+0(1).
IF CHECKTABLED NE 'Z'.
MESSAGE I017.
LEAVE TO SCREEN 1000.
ENDIF.
IF SY-UNAME NE 'KAMESH.K'.
MESSAGE I023 WITH SY-UNAME.
LEAVE TO SCREEN 1000.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR MFILENAM .
PERFORM F4_FOR_FILENAME .
INITIALIZATION .
T_TABL = 'Table Name' .
T_FILE = 'File Name' .
T_DOWN = 'Download Table' .
T_CHKF = 'Check File to Upload' .
T_UPLD = 'Upload File' .
T_SHOW = 'Show Table Contents' .
START-OF-SELECTION .
PERFORM CHECK_TABLE_NAME_IS_VALID .
END-OF-SELECTION .
IF TABLE_NAME_IS_VALID EQ ' ' .
MESSAGE I398(00) WITH 'INVALID TABLE NAME' .
ELSE .
PERFORM INSTANTIATE_DYNAMIC_INTERNAL_T .
CHECK DYNAMIC_IT_INSTANTIATED = 'X' .
CASE BUTTONSELECTED .
WHEN P_DOWNLD .
PERFORM SELECT_AND_DOWNLOAD .
WHEN P_CHKFIL .
PERFORM CHECK_FILE_TO_UPLOAD .
WHEN P_UPLOAD .
PERFORM UPLOAD_FROM_FILE .
WHEN P_SHOW_T .
PERFORM SHOW_CONTENTS .
ENDCASE .
ENDIF .
FORM CHECK_TABLE_NAME_IS_VALID.
DATA MCOUNT TYPE I .
TABLES DD02L .
CLEAR TABLE_NAME_IS_VALID .
SELECT COUNT(*) INTO MCOUNT FROM TADIR
WHERE PGMID = 'R3TR'
AND OBJECT = 'TABL'
AND OBJ_NAME = MTABLE_N .
IF MCOUNT EQ 1 .
CLEAR DD02L .
SELECT SINGLE * FROM DD02L WHERE TABNAME = MTABLE_N .
IF SY-SUBRC EQ 0.
IF DD02L-TABCLASS = 'TRANSP' .
TABLE_NAME_IS_VALID = 'X' .
ENDIF .
ENDIF.
ENDIF .
ENDFORM. " CHECK_TABLE_NAME_IS_VALID
FORM SELECT_AND_DOWNLOAD.
CLEAR : <FS_ITAB> .
SELECT * FROM (MTABLE_N)
INTO CORRESPONDING FIELDS OF TABLE <FS_ITAB> .
PERFORM CHECK_FILENAME.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = MFILENAM
FILETYPE = 'DAT'
TABLES
DATA_TAB = <FS_ITAB>
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 EQ 0.
MESSAGE I398(00) WITH 'Table' MTABLE_N
'successfully downloaded to '
MFILENAM .
ENDIF.
ENDFORM. " SELECT_AND_DOWNLOAD
FORM UPLOAD_FROM_FILE.
DATA : ANS TYPE C .
DATA : LINES_OF_ITAB TYPE I .
DATA : MSY_SUBRC TYPE I .
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
TEXTLINE1 = 'Are you sure you wish to upload'
TEXTLINE2 = 'data from ASCII File to DB table '
TITEL = 'Confirmation of Data Upload'
IMPORTING
ANSWER = ANS.
IF ANS = 'J' .
PERFORM CHECK_FILENAME.
CLEAR MSY_SUBRC .
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = MFILENAM
FILETYPE = 'DAT'
TABLES
DATA_TAB = <FS_ITAB>
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10.
MSY_SUBRC = MSY_SUBRC + SY-SUBRC .
IF SY-SUBRC EQ 0.
DESCRIBE TABLE <FS_ITAB> LINES LINES_OF_ITAB .
IF LINES_OF_ITAB GT 0 .
MODIFY (MTABLE_N) FROM TABLE <FS_ITAB> .
MSY_SUBRC = MSY_SUBRC + SY-SUBRC .
ENDIF .
ENDIF.
IF MSY_SUBRC EQ 0 .
MESSAGE I398(00) WITH LINES_OF_ITAB
'Record(s) inserted in table'
MTABLE_N .
ELSE .
MESSAGE I398(00) WITH
'Errors occurred No Records inserted in table'
MTABLE_N .
ENDIF .
ENDIF .
ENDFORM. " UPLOAD_FROM_FILE
FORM F4_FOR_FILENAME.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_PATH = 'C:\'
MASK = ',.,..'
MODE = '0'
IMPORTING
FILENAME = MFILENAM
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
ENDFORM. " F4_FOR_FILENAME
FORM CHECK_FILENAME.
IF MFILENAM IS INITIAL
AND NOT ( MTABLE_N IS INITIAL )
AND P_SHOW_T NE BUTTONSELECTED.
CONCATENATE 'C:\'
MTABLE_N '.TXT' INTO MFILENAM.
ENDIF .
ENDFORM. " CHECK_FILENAME
FORM INSTANTIATE_DYNAMIC_INTERNAL_T.
CLEAR DYNAMIC_IT_INSTANTIATED .
I_STRUCTURE_NAME = MTABLE_N .
CLEAR IT_FIELDCAT[] .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = I_STRUCTURE_NAME
CHANGING
CT_FIELDCAT = IT_FIELDCAT[]
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC EQ 0.
LOOP AT IT_FIELDCAT .
CLEAR WA_FIELDCATALOG .
MOVE-CORRESPONDING IT_FIELDCAT TO WA_FIELDCATALOG .
WA_FIELDCATALOG-REF_FIELD = IT_FIELDCAT-FIELDNAME .
WA_FIELDCATALOG-REF_TABLE = MTABLE_N .
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG .
ENDLOOP .
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_FIELDCATALOG
IMPORTING
EP_TABLE = MITAB .
ASSIGN MITAB->* TO <FS_ITAB> .
DYNAMIC_IT_INSTANTIATED = 'X' .
ENDIF.
ENDFORM. " INSTANTIATE_DYNAMIC_INTERNAL_T
FORM SHOW_CONTENTS.
CLEAR : <FS_ITAB> .
SELECT * FROM (MTABLE_N)
INTO CORRESPONDING FIELDS OF TABLE <FS_ITAB> .
I_CALLBACK_PROGRAM = SY-REPID .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = I_CALLBACK_PROGRAM
IT_FIELDCAT = IT_FIELDCAT[]
TABLES
T_OUTTAB = <FS_ITAB>
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM. " SHOW_CONTENTS
FORM CHECK_FILE_TO_UPLOAD.
PERFORM CHECK_FILENAME.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = MFILENAM
FILETYPE = 'DAT'
TABLES
DATA_TAB = <FS_ITAB>
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 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 EQ 0.
I_CALLBACK_PROGRAM = SY-REPID .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = I_CALLBACK_PROGRAM
IT_FIELDCAT = IT_FIELDCAT[]
TABLES
T_OUTTAB = <FS_ITAB>
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDIF .
ENDFORM. " CHECK_FILE_TO_UPLOAD
Message was edited by:
SAURABH SINGH
SENIOR EXECUTIVE
SAMSUNG INDIA ELECTRONICS LTD.,NOIDA -
How to upload a file in application server to an internal table
Hi,
I am asked to upload a file from application server to internal table. Can you please suggest me the ways to do it or the function module which helps to browse the application server file names.
I have done a program. But its giving problem in searching the files from application server. I am pasting my code for ur review. Please tell me which part i have to correct or suggest me some other ways to do it.
*& Report ZUPLOAD1
REPORT ZUPLOAD1.
type-pools: truxs.
parameters: p_upl_ps radiobutton group g1 default 'X', "upload from pres. server
p_path type rlgrap-filename,
p_upl_as radiobutton group g1, "upload from appln server
<b>p_dir LIKE filepath-pathintern DEFAULT 'Y_ABAP',
p_file LIKE filepath-pathintern lower case,</b>
p_test as checkbox.
constants: c_x value 'X',
c_tab type c value cl_abap_char_utilities=>horizontal_tab.
types: ty_data(1000) type c. "structure to hold legacy data
data: i_data type standard table of ty_data. "internal table of ty_data
types: begin of stritab,
land1 type v_t604-land1, "structure of legacy file.
stawn type v_t604-stawn,
bemeh type v_t604-bemeh,
impma type v_t604-impma,
minol type v_t604-minol,
end of stritab.
data: gi_itab type standard table of stritab, "internal table of legacy file
gw_itab type stritab. "work area
data: i_raw type truxs_t_text_data,
v_fullpath type string.
at selection-screen on value-request for p_path.
if p_upl_ps = c_x. "if presentation server is selected
perform get_file.
else. "if application server is selected
perform set_file_path.
perform upload_from_server.
perform split_data.
endif.
form get_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = p_path. "getting the file name of pres server
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X' "converting excel to sap and filling in
I_TAB_RAW_DATA = i_raw "internal table
I_FILENAME = p_path
TABLES
I_TAB_CONVERTED_DATA = gi_itab
EXCEPTIONS
CONVERSION_FAILED = 1
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.
ENDIF.
endform.
form set_file_path. "Getting the file path of application server
data: lv_file type p_file.
lv_file = p_file.
CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
EXPORTING
CLIENT = SY-MANDT
LOGICAL_PATH = p_dir
OPERATING_SYSTEM = SY-OPSYS
PARAMETER_1 = ' '
PARAMETER_2 = ' '
PARAMETER_3 = ' '
USE_BUFFER = ' '
FILE_NAME = lv_file
USE_PRESENTATION_SERVER = ' '
ELEMINATE_BLANKS = 'X'
IMPORTING
FILE_NAME_WITH_PATH = v_fullpath
EXCEPTIONS
PATH_NOT_FOUND = 1
MISSING_PARAMETER = 2
OPERATING_SYSTEM_NOT_FOUND = 3
FILE_SYSTEM_NOT_FOUND = 4
OTHERS = 5
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.
form upload_from_server.
data: lv_msg type string,
lw_data type ty_data.
open dataset v_fullpath for input message lv_msg in text mode encoding default.
if sy-subrc <> 0.
message lv_msg type 'i'.
stop.
endif.
do.
read dataset v_fullpath into lw_data.
if sy-subrc <> 0.
write:/5 'Error in processign data set'.
exit.
endif.
append lw_data to i_data.
enddo.
close dataset v_fullpath.
if sy-subrc <> 0.
write: /5 'Error closing dataset'.
endif.
endform.
form split_data.
data: lw_data type ty_data.
data: lw_itab type stritab.
data: begin of ty_itab,
land1 type v_t604-land1,
stawn type v_t604-stawn,
bemeh type v_t604-bemeh,
impma type v_t604-impma,
minol type v_t604-minol,
end of ty_itab.
loop at i_data into lw_data.
split lw_data at c_tab into
ty_itab-land1
ty_itab-stawn
ty_itab-bemeh
ty_itab-impma
ty_itab-minol.
lw_itab-land1 = ty_itab-land1.
lw_itab-stawn = ty_itab-stawn.
lw_itab-bemeh = ty_itab-bemeh.
lw_itab-impma = ty_itab-impma.
lw_itab-minol = ty_itab-minol.
append lw_itab to gi_itab.
endloop.
endform.
start-of-selection.
loop at gi_itab into gw_itab.
write: /5 'COUNTRY', 'IMPORT CODE', 'SUP UNIT', 'FIRST UOM', 'SECOND UOM',
/5 gw_itab-land1, gw_itab-stawn,gw_itab-bemeh,gw_itab-impma,gw_itab-minol.
endloop.
end-of-selection.
I hope problem must be in p_dir and p_file which are in bold.. Kindly help me out. Thanks in advance.see the following ex:
*& Form SUB_GET_FILEPATH
text
--> p1 text
<-- p2 text
FORM SUB_GET_FILEPATH .
GFILE = 'D:\SAP_INT\INBOUND\INBOX'. "Path
ENDFORM. " SUB_GET_FILEPATH
*& Form SUB_GET_FILE
text
--> p1 text
<-- p2 text
FORM SUB_GET_FILE .
DATA: P_FDIR(200) TYPE C.
DATA: IT_FILEDIR1 TYPE STANDARD TABLE OF TY_FILEDIR WITH HEADER LINE.
P_FDIR = GFILE.
CALL FUNCTION 'RZL_READ_DIR_LOCAL'
EXPORTING
NAME = P_FDIR
TABLES
FILE_TBL = IT_FILEDIR.
REFRESH : IT_FILEDIR1.
LOOP AT IT_FILEDIR.
IF IT_FILEDIR-NAME(4) = 'ZINC' OR IT_FILEDIR-NAME(4) = 'zinc'.
MOVE IT_FILEDIR-NAME TO IT_FILEDIR1-NAME.
APPEND IT_FILEDIR1.
ENDIF.
ENDLOOP.
IF IT_FILEDIR1[] IS INITIAL.
STOP.
ENDIF.
LOOP AT IT_FILEDIR1.
REFRESH: I_TAB.
CLEAR: I_TAB.
NAME = IT_FILEDIR1-NAME.
CONCATENATE: GFILE '\' NAME INTO G_FILE.
OPEN DATASET G_FILE FOR INPUT IN TEXT MODE
ENCODING DEFAULT
IGNORING CONVERSION ERRORS.
IF SY-SUBRC EQ 0.
CONCATENATE 'FILENAME : ' G_FILE INTO I_MSG1.
APPEND I_MSG1.
DO.
READ DATASET G_FILE INTO RECORD.
IF SY-SUBRC = 0.
SPLIT RECORD AT ',' INTO I_TAB-BUKRS I_TAB-EBELN
I_TAB-BLDAT I_TAB-XBLNR I_TAB-LIFNR I_TAB-AMOUNT
I_TAB-CURR I_TAB-BUSAREA
I_TAB-BKTXT I_TAB-DMBTR I_TAB-MENGE I_TAB-SRNO.
MOVE-CORRESPONDING I_TAB TO I_TAB1.
ELSE.
EXIT.
ENDIF.
APPEND I_TAB1.
CLEAR: I_TAB, I_TAB1.
ENDDO.
ENDIF.
CLOSE DATASET G_FILE. -
Use 3 internal table in GUI_Download
Hello expert,
i have 3 internal table: gt_header, gt_body and gt_footer. how can i used all 3 in gui_download fm. here is my sample code:
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = gv_file_name
filetype = 'ASC'
TABLES
data_tab = gt_header.
here i can only pass one internal table.
Help please?Hi Hassim,
Maybe you can declare another internal table, with all fields is type C and length as you wanted.
Loop those three itabs, append to this new itab. then call this FM download.
regards,
Archer -
IMPORT Statement Issue (Internal Table)
Hi All,
I am using an IMPORT statement to get all the data from other report's internal table. Now whenever this (the other report's internal table) is changed (for field addition, etc), my report throws a dump. Hence, everytime I have to add these fields in my program as well.
Is there any way by which I can include the whole internal table of that report in my program just like
'INCLUDE STRUCTURE VBRK'.
Thanks in advanceHi, CHeck this code related to your problem..This will helpful to you...
I have done this program earlier..I hope it will helpful to u..
This programa calling the other program to import the data..
Check it out...
*" Tables declarations.................................................
TABLES:
spfli.
*" Type declarations...................................................
Type declaration of the structure to hold data from table SPFLI *
TYPES:
BEGIN OF type_s_spfli,
carrid LIKE spfli-carrid, " Carrier Id
connid LIKE spfli-connid, " Connection Number
cityfrom LIKE spfli-cityfrom, " City from
cityto LIKE spfli-cityto, " City to
airpfrom LIKE spfli-airpfrom, " Airport from
airpto LIKE spfli-airpto, " Airport to
countryfr LIKE spfli-countryfr, " Country from
countryto LIKE spfli-countryto, " Country to
END OF type_s_spfli.
Data Declaration...................................................*
Field String To Hold Flight Details Record from SPFLI *
DATA
fs_spfli TYPE type_s_spfli.
Data Declaration...................................................*
Internal Table To Hold Flight Details Records from SPFLI *
DATA
t_spfli LIKE STANDARD TABLE OF fs_spfli.
TYPES:
BEGIN OF types_s_itab,
carrid LIKE sflight-carrid, " Carrier id
connid LIKE sflight-connid, " Connection number
fldate LIKE sflight-fldate, " Flight date
END OF types_s_itab.
Data Declaration...................................................*
Field String To Hold Flight Details Record from SFLIGHT *
DATA
fs_itab TYPE types_s_itab.
Data Declaration...................................................*
Internal Table To Hold Flight Details Records from SFLIGHT *
DATA
t_itab LIKE STANDARD TABLE OF fs_itab.
*" Type declarations...................................................
Type declaration of the structure to hold data from table SBOOK *
TYPES:
BEGIN OF type_s_sbook,
carrid LIKE sbook-carrid, " Carrier Id
connid LIKE sbook-connid, " Connection Number
fldate LIKE sbook-fldate, " Flight date
bookid LIKE sbook-bookid, " Booking number
loccuram LIKE sbook-loccuram, " Local currency
loccurkey LIKE sbook-loccurkey,
order_date LIKE sbook-order_date, " Booking date
END OF type_s_sbook.
Data Declaration...................................................*
Field String To Hold Flight Details Record from BOOK *
DATA
fs_sbook TYPE type_s_sbook.
Data Declaration...................................................*
Internal Table To Hold Flight Details Records from SBOOK *
DATA
t_sbook LIKE STANDARD TABLE OF fs_sbook.
DATA
w_checkbox. " Checkbox
SELECT-OPTIONS:
s_carr FOR spfli-carrid. " Carrier id range
START-OF-SELECTION EVENT *
START-OF-SELECTION.
PERFORM selectq.
END-OF-SELECTION EVENT *
END-OF-SELECTION.
SET PF-STATUS 'YH1314_030502'.
PERFORM display_basic.
AT USER-COMMAND.
PERFORM ucomm.
*& Form selectq
This subroutine retreive data from SPFLI table
There are no interface parameters to be passed to this subroutine.
FORM selectq .
SELECT carrid " Carrier id
connid " Connection number
cityfrom " City from
cityto " City to
airpfrom " Airport from
airpto " Airport to
countryfr " Country from
countryto " Country to
INTO CORRESPONDING FIELDS OF TABLE t_spfli
FROM spfli
WHERE carrid IN s_carr.
ENDFORM. " Selectq
*& Form display_basic
This subroutine displays data from internal table
There are no interface parameters to be passed to this subroutine.
FORM display_basic .
LOOP AT t_spfli INTO fs_spfli.
WRITE:
/ w_checkbox AS CHECKBOX,
fs_spfli-carrid,
fs_spfli-connid,
fs_spfli-cityfrom,
fs_spfli-cityto,
fs_spfli-airpfrom,
fs_spfli-airpto,
fs_spfli-countryfr,
fs_spfli-countryto.
ENDLOOP. " LOOP AT T-SPFLI INTO...
ENDFORM. " Display_basic
*& Form UCOMM
This subroutine for at user-command event
There are no interface parameters to be passed to this subroutine.
FORM ucomm .
RANGES :
r_carr FOR spfli-carrid,
r_conn FOR spfli-connid,
r_carrid FOR sflight-carrid,
r_connid FOR sflight-connid,
r_fldate FOR sflight-fldate.
CASE sy-ucomm.
WHEN 'DISPLAY'.
DATA:
lw_lines TYPE i,
lw_lineno TYPE i VALUE 3.
DESCRIBE TABLE t_spfli LINES lw_lines.
DO lw_lines TIMES.
READ LINE lw_lineno FIELD
VALUE w_checkbox INTO w_checkbox
fs_spfli-carrid INTO fs_spfli-carrid
fs_spfli-connid INTO fs_spfli-connid.
IF sy-subrc = 0.
IF w_checkbox = 'X'.
r_carr-sign = 'I'.
r_carr-option = 'EQ'.
r_carr-low = fs_spfli-carrid.
APPEND r_carr.
r_conn-sign = 'I'.
r_conn-option = 'EQ'.
r_conn-low = fs_spfli-connid.
APPEND r_conn.
ENDIF. " IF W_CHECKBOX = 'X'
ENDIF. " IF SY-SUBRC = 0
ADD 1 TO lw_lineno.
ENDDO. " DO LW_LINES TIMES
SUBMIT yh1314_030502_call
WITH s_carr IN r_carr
WITH s_conn IN r_conn
AND RETURN.
IMPORT t_itab FROM MEMORY ID 'YH1314'.
LOOP AT t_itab INTO fs_itab.
r_carrid-sign = 'I'.
r_carrid-option = 'EQ'.
r_carrid-low = fs_itab-carrid.
APPEND r_carrid.
r_connid-sign = 'I'.
r_connid-option = 'EQ'.
r_connid-low = fs_itab-connid.
APPEND r_connid.
r_fldate-sign = 'I'.
r_fldate-option = 'EQ'.
r_fldate-low = fs_itab-fldate.
APPEND r_fldate.
ENDLOOP. " LOOP AT T_ITAB INTO.....
SELECT carrid " Carriee Id
connid " Connection number
fldate " Flight date
bookid " Booking number
loccuram " Local Currency
order_date " Booking date
INTO CORRESPONDING FIELDS OF TABLE t_sbook
FROM sbook
WHERE carrid IN r_carrid AND
connid IN r_connid AND
fldate IN r_fldate.
IF SY-SUBRC NE 0.
MESSAGE 'NO RECORDS FOUND'(006) TYPE 'S'.
ENDIF. " IF SY-SUBRC NE 0
LOOP AT t_sbook INTO fs_sbook.
AT FIRST.
WRITE: /5 'Carrier Id'(001),
20 'Conn Id'(002),
35 'Flight date'(003),
50 'Book Id'(004),
65 'Local Currency'(005).
ENDAT. " AT FIRST
WRITE: /5 fs_sbook-carrid,
20 fs_sbook-connid,
35 fs_sbook-fldate,
50 fs_sbook-bookid,
65 fs_sbook-loccuram CURRENCY fs_sbook-loccurkey.
ENDLOOP. " LOOP AT T_SBOOK INTO.....
ENDCASE. " CASE SY-UCOMM
ENDFORM. " UCOMM
Regards
Kiran -
Can not insert or update [TABLE] from internal table in method
I've faced a problem with OO abap. I've tried to insert into [ TABLE ] from internal table, but i've got error msg after i compiled.
"An explicit work area is necessary in the OO context. Use "INSERT wa INTO [TABLE] itab""
After i changed to loop in work area and INSERT INTO [TABLE] VALUES gw_data., everything is fine, can compile and run.
This is error code.
METHOD set_data_to_table.
REFRESH gi_data.
CLEAR gi_data.
IF gi_file[] IS NOT INITIAL.
* Set data for modify table
LOOP AT gi_file INTO gw_file.
MOVE-CORRESPONDING gw_file TO gw_data.
me->conversion_input( EXPORTING im_vendor = gw_data-vendor
CHANGING ch_vendor = gw_data-vendor ).
APPEND gw_data TO gi_data.
ENDLOOP.
INSERT [TABLE] FROM TABLE gi_data.
* LOOP AT gi_data INTO gw_data.
* INSERT INTO [TABLE] VALUES gw_data.
* IF sy-subrc = 0.
* COMMIT WORK.
* ELSE.
* ROLLBACK WORK.
* ENDIF.
* ENDLOOP.
ELSE.
MESSAGE 'No data found' TYPE 'I'.
ENDIF.
ENDMETHOD. "set_data_to_tableHi Matthew,
I think there is no difference in database insert between OO and non-OO.
The correct syntax according to ECC600 online documentation is
[Inserting Several Lines|http://help.sap.com/saphelp_erp2005vp/helpdata/en/fc/eb3a6d358411d1829f0000e829fbfe/content.htm]
To insert several lines into a database table, use the following:
INSERT target FROM TABLE itab \[ACCEPTING DUPLICATE KEYS].
This writes all lines of the internal table itabto the database table in one single operation. If one or more lines cannot be inserted because the database already contains a line with the same primary key, a runtime error occurs. You can prevent the runtime error occurring by using the addition ACCEPTING DUPLICATE KEYS.
Whenever you want to insert more than one line into a database table, it is more efficient to work with an internal table than to insert the lines one by one.
I think the syntax
INSERT my_dbtable FROM TABLE gi_data.
should work, your suggestion may lead to syntax error.
Regards,
Clemens -
Update internal table data from table control
Hi GURUS,
I need help regarding one of my requirement.
I need to display data from the internal table on the screen and when the user selects a record/multiple records from screen and clicks on approve button i need to update one of the field from N to Y in the corresponding Ztable. Once the record is updated from Ztable , that should no longer be visible for the user on the screen.
I am using table control wizard to display data. I am able to update the Ztable, but that record is not refreshing from the user screen. Any suggestions would be approved.
Also please let me know if table control is the best way to do this/ alv grid control??hi
REFRESH CONTROL Control-Name FROM SCREEN '0100' -> use this command to refresh the table control
to know more, read into
https://forums.sdn.sap.com/click.jspa?searchID=2934287&messageID=673474
Re: URGENT HELP REQ IN TABLE CONTROL WIZARD
if helpful, reward
Sathish. R -
Copy a certain row of data into the next row in a same internal table ??
HI, guys.
May i know how to copy a certain row of data into the next row in a same internal table ?? Bcz I plan to update a certain colum of data in the row just now into another value..
For example:-
*at first...
ebeln1 ebelp1 xblnr1
ebeln2 ebelp2 xblnr2
ebeln3 ebelp3 xblnr3
*after that, become...
ebeln1 ebelp1 xblnr1
ebeln2 ebelp2 xblnr2
ebeln2 ebelp2 xblnr4
ebeln2 ebelp2 xblnr5
ebeln3 ebelp3 xblnr3
Thanks in advance.hi,
If you have this kind of requirement then you must be having 2 internal tables ,one existing data and 2nd from which you have to insert the records into 1st table.
so in this case,
loop at itab1.
v_index = sy-tabix.
loop at itab2 into wa where pri_key = itab1-pri_key.
v_index = v_index + 1.
insert wa into itab index v_index.
endloop.
endloop.
Using this code ,your data records similar to your 1st tables primary key records will get inserted into table. -
Unable to Capture ALV output in an Internal Table, after CALL TRANSACTION
Dear all,
My requirement is to run multiple materials in T-code CK86_99 but as we know CK86_99 is only adequate to one material at a time.
So, I want to capture the Output of the T-code in my Internal table with respect to all the Material Numbers I use in the Select-Options of my Z Program.
Below is the Code I developed so far, but the Class
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = lf_ref ).
is not capturing the Ouput...
Please have a look and enlighten me how it could be solved.
TABLES : mara.
DATA : BEGIN OF wa_mara,
matnr TYPE mara-matnr,
END OF wa_mara.
DATA: it_bdcdata TYPE TABLE OF bdcdata,
wa_it_bdcdata LIKE LINE OF it_bdcdata,
it_mara LIKE TABLE OF wa_mara.
* BELNR(10).
FIELD-SYMBOLS:<fs_tab> TYPE ANY TABLE,
<fs_line> TYPE any.
DATA:lf_ref TYPE REF TO data,
lf_ref1 TYPE REF TO data.
SELECT-OPTIONS so_matnr FOR mara-matnr.
PARAMETERS p_werks LIKE t001w-werks.
*BELNR = 'Z92'. " Give Document Number here
SELECT matnr FROM mara INTO TABLE it_mara WHERE matnr IN so_matnr.
DATA opt TYPE ctu_params.
LOOP AT it_mara INTO wa_mara.
CLEAR wa_it_bdcdata.
wa_it_bdcdata-program = 'SAPMKKB0'.
wa_it_bdcdata-dynpro = '0300'.
wa_it_bdcdata-dynbegin = 'X'.
APPEND wa_it_bdcdata TO it_bdcdata.
CLEAR wa_it_bdcdata.
wa_it_bdcdata-fnam = 'BDC_CURSOR'.
wa_it_bdcdata-fval = 'KKB0-MATNR'.
APPEND wa_it_bdcdata TO it_bdcdata.
CLEAR wa_it_bdcdata.
wa_it_bdcdata-fnam = 'KKB0-MATNR'.
wa_it_bdcdata-fval = wa_mara-matnr.
APPEND wa_it_bdcdata TO it_bdcdata.
CLEAR wa_it_bdcdata.
wa_it_bdcdata-fnam = 'BDC_CURSOR'.
wa_it_bdcdata-fval = 'KKB0-WERKS'.
APPEND wa_it_bdcdata TO it_bdcdata.
CLEAR wa_it_bdcdata.
wa_it_bdcdata-fnam = 'KKB0-WERKS'.
wa_it_bdcdata-fval = p_werks.
APPEND wa_it_bdcdata TO it_bdcdata.
CLEAR wa_it_bdcdata.
wa_it_bdcdata-fnam = 'BDC_OKCODE'.
wa_it_bdcdata-fval = 'OSNY'."'ONLI'."=CRET'.
APPEND wa_it_bdcdata TO it_bdcdata.
* CLEAR wa_it_bdcdata.
* wa_it_bdcdata-program = 'SAPLKKRSOO'.
* wa_it_bdcdata-dynpro = '0100'.
* wa_it_bdcdata-dynbegin = 'X'.
* APPEND wa_it_bdcdata TO it_bdcdata.
* CLEAR wa_it_bdcdata.
* wa_it_bdcdata-fnam = 'BDC_OKCODE'.
* wa_it_bdcdata-fval = 'BACK'."=CRET'.
* APPEND wa_it_bdcdata TO it_bdcdata.
* CLEAR wa_it_bdcdata.
* wa_it_bdcdata-program = 'SAPMKKB0'.
* wa_it_bdcdata-dynpro = '0300'.
* wa_it_bdcdata-dynbegin = 'X'.
* APPEND wa_it_bdcdata TO it_bdcdata.
* CLEAR wa_it_bdcdata.
* wa_it_bdcdata-fnam = 'BDC_OKCODE'.
* wa_it_bdcdata-fval = 'EXIT'."=CRET'.
* APPEND wa_it_bdcdata TO it_bdcdata.
opt-dismode = 'N'.
cl_salv_bs_runtime_info=>set(
EXPORTING display = abap_false
metadata = abap_true
data = abap_true ).
CALL TRANSACTION 'CK86_99' USING it_bdcdata OPTIONS FROM opt.
TRY.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = lf_ref ).
ASSIGN lf_ref->* TO <fs_tab>.
CATCH cx_salv_bs_sc_runtime_info.
MESSAGE 'Unable to retrieve ALV data' TYPE 'E'.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
IF <fs_tab> IS ASSIGNED.
CREATE DATA lf_ref1 LIKE LINE OF <fs_tab>.
ASSIGN lf_ref1->* TO <fs_line>.
ENDIF.
*LOOP AT <FS_TAB> ASSIGNING <FS_LINE>.
*ENDLOOP.Hi Abhay,
If you go to Transaction code SE93, enter the tcode "CK86_99" and click display, you may see the default value for transaction is "KKBB" and the screen field for P_SCREEN = 0300, P_TCODE = ck86_99.
You may need to copy the transaction code "KKBB" and go to SE93 again, enter the tcode for "KKBB" then click display, now you may see the program name is "RKKB1000".
Hope this answer your question.
Thanks
Hock Lin
Maybe you are looking for
-
How do I transfer some photos from an external harddrive (with backup data from one macbook) to another macbook? Ideally, I'd also like to transfer albums as well that photos are linked to. I need to do this because my macbook is broken and I need t
-
How can I print in black and white?
I have asked friends how to print in black and white and they show me how to do it on their computers. They do it by just switching the colorysync profile to black and white or greyscale but when I go to print and go to the same drop down menu for co
-
Does Log reader agent use sa in sp_replcmds?
We have publisher, subscriber, and distributor on separate servers. Replication is Push Transactional with replication agents setup to run under SQL Agent account context. We are in the process of disabling sa from everywhere and I am monitoring sess
-
Oracle Reports Parameter List form called through URL bring blank page
We are using 10g Release 2 We are able to load balance all other reports out there. 1. Using run_report_objects in oracle forms 2. Using a URL to call a report directly with parameters. However we are unable to use the URL function if there there is
-
Nolonger have iclould email address but I need it for my password to change
I no longer have the email address attached to the icloud account to gt email, but I need to change my password..help plese?