data: l_lines type i,"存放内表ITAB的记录数
l_times type i."当前循环的次数
Describe ITAB Lines l_lines."获取内表ITAB的记录数
Loop at ITAB into Wa.
l_times = l_times + 1."循环次数加1
IF l_times = 1."第一次循环,Wa2-zhsj1为空
Concatenate Wa-B '/' into Wa2-zhsj1.
ELSEIF l_times = l_lines."如果当前循环的次数等于内表ITAB的记录数
Concatenate Wa2-zhsj1 Wa-B into Wa2-zhsj1."则不需要加‘/’
ELSE.
Concatenate Wa2-zhsj1 '/' Wa-B Into Wa2-zhsj1."否则,要添加‘/’
ENDIF.
Endloop.
Append Wa2 to ITAB2.
LOOP AT ITAB INTO WA
WA2-ZHSJ1 = WA-B
APPEND WA2 TO ITAB2
ENDLOOP.
没怎么明白你的意思
循环ITAB到工作区,然后将工作区对应字段再付给与ITAB2对应的工作区WA2,
最后把WA2弄到ITAB2里
data: str(20) type c.
loop at itab.
CONCATENATE str ITAB-B INTO str SEPARATED BY '/'
endloop.
itab2-zhsj1 = str.
append itab2.
思路是先对itab-B循环取数,然后用concatenate语句将所有取出来的值放入你所定义的新字段中(这一步操作可以结合在对itab进行每一次循环的过程中)
LOOP AT ITAB INTO WA_ITAB.
CONCATENATE ITAB2-zhsj1 WA_ITAB-B INTO ITAB2-zhsj1 SEPARATED BY '/'.
*----- 要不要APPEND ITAB2看你需求
ENDLOOP.